本文整理汇总了PHP中db::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP db::connect方法的具体用法?PHP db::connect怎么用?PHP db::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db
的用法示例。
在下文中一共展示了db::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: close_connect
/**
* Lezárja az adatbázis kapcsolatot (A PDO objektum-hoz a null értéket rendeli hozzá)
*/
public static function close_connect()
{
if (self::$connect != null) {
self::$connect = null;
}
return self::$connect;
}
示例2: GuardarAlbaranes
public function GuardarAlbaranes()
{
$db = new db();
$db->connect();
$C = new ActiveRecord('albaranes');
$C->fields["fecha"] = $this->fecha;
$C->fields["operacion"] = $this->operacion;
$C->fields["guia"] = $this->guia;
$C->fields["remitente"] = $this->remitente;
$C->fields["beneficiario"] = $this->beneficiario;
$C->fields["documento"] = $this->documento;
$C->fields["pais"] = $this->pais;
$C->fields["direccion"] = $this->direccion;
$C->fields["ciudad"] = $this->ciudad;
$C->fields["telefono"] = $this->telefono;
$C->fields["descripcion"] = $this->descripcion;
$C->fields["peso"] = $this->peso;
$C->fields["comision"] = $this->comision;
$C->fields["seguro"] = $this->seguro;
$C->fields["iv"] = $this->iv;
$C->fields["total"] = $this->total;
$C->fields["direccion_agencia"] = $this->direccion_agencia;
$C->insert();
$db->close();
}
示例3: authenticate
function authenticate($U, $P, $recordar = 0, $by = 'usuario')
{
$RESULT = false;
if (trim($U) != '' && trim($P) != '') {
$db = new db();
$db->connect();
$sql = ' SELECT * FROM usuarios
WHERE ( ' . $by . ' = "' . mysql_real_escape_string($U) . '" )
AND ( password = "' . md5($P) . '" )
';
$db->query($sql);
// no existe
$RESULT = false;
while ($record = $db->next()) {
// LOGEAR
$this->creaSession($record);
$RESULT = true;
if ($recordar) {
$two_months = time() + 30 * 24 * 3600;
setcookie('id_usuario', $U, $two_months);
setcookie('contrasena', $P, $two_months);
}
}
$db->close();
}
return $RESULT;
}
示例4: getDB
private function getDB($token)
{
if (!$token) {
return hg_ConnectDB();
}
$servindex = $this->get_serv_index($token);
$servindex = $servindex - 1;
if ($servindex == -1) {
$ServDB = hg_ConnectDB();
$this->iscp = true;
} else {
$this->iscp = false;
$servers = hg_load_login_serv();
if (!$servers) {
$ServDB = hg_ConnectDB();
} else {
$server = $servers[$servindex];
if ($server) {
include_once ROOT_PATH . 'lib/db/db_mysql.class.php';
$ServDB = new db();
$server['pass'] = hg_encript_str($server['pass'], false);
$ServDB->connect($server['host'], $server['user'], $server['pass'], $server['database'], $server['charset'], $server['pconnect']);
$this->dbname = $server['database'] . '.';
} else {
$ServDB = hg_ConnectDB();
}
}
}
return $ServDB;
}
示例5: getTableDS
public function getTableDS($table)
{
$sql = 'SELECT * FROM ' . $table . ' ORDER BY id';
db::connect();
$result = db::dataSource($sql);
return $result;
}
示例6: _prepare
private function _prepare()
{
db::connect();
dibi::addSubst('table', 'students');
dibi::addSubst('courses_students', 'courses_students');
dibi::addSubst('courses', 'courses');
}
示例7: userInfo
public function userInfo($id)
{
$bd = new db();
$bd->connect();
$this->query = mysql_query("SELECT * FROM users WHERE id = '{$id}'") or die(mysql_error());
$this->data = mysql_fetch_array($this->query);
return $this->data;
}
示例8: insertIntoPlaylistIndex
private function insertIntoPlaylistIndex($videoID, $playlist)
{
$db = new db();
$db->connect();
$videoID = mysql_real_escape_string($videoID);
$query = "INSERT INTO playlistindex ( id, video ) VALUES ( '{$playlist}' , '{$videoID}' );";
$result = mysql_query($query) or die('Could not add video.');
mysql_close();
}
示例9: getDate
public function getDate($id)
{
$db = new db();
$db->connect();
$query = "SELECT publishedOn FROM videos WHERE id = '{$id}' LIMIT 1;";
$result = mysql_query($query);
$data = mysql_fetch_assoc($result, MYSQL_ASSOC);
$date = $data['publishedOn'];
return strtotime($date) == strtotime("0") ? strtotime("06/01/2015") : strtotime($date);
}
示例10: getPage
function getPage()
{
$page = checkPage();
$db = new db();
$db->connect();
$pageData = getPageData($page);
if (count($pageData) <= 1) {
$pageData = getPageData("404");
header("HTTP/1.1 404 Not Found");
}
sendPage($pageData);
}
示例11: actionIndex
public function actionIndex()
{
$model = new Install();
$file = base_path() . 'config/database.php';
if (!is_writable($file)) {
$data['error'] = __('config/database.php is not writable');
}
$model->host = "localhost";
if ($model->load($_POST)) {
if (!$data['error']) {
$dsn = "mysql:host=" . trim($model->host) . ";dbname=" . trim($model->host_db);
$username = trim($model->host_user);
$model->host_pwd = $password = trim($_POST['Install']['host_pwd']);
$db = new \db();
$db->connect($dsn, $username, $password);
if (!$db->id) {
$data['error'] = __('connect host failed');
} else {
$content = \Yii::getAlias('@application/config/database.php');
$content = file_get_contents($content);
$content = str_replace('{dsn}', $dsn, $content);
$content = str_replace('{user}', $username, $content);
$content = str_replace('{pwd}', $password, $content);
file_put_contents($file, $content);
$rows = $db->query("SHOW TABLES")->all();
if ($rows) {
foreach ($rows as $r) {
foreach ($r as $v) {
$li[] = $v;
}
}
}
if (!$li || !in_array('auth_access', $li)) {
$row = $db->query("SHOW VARIABLES LIKE '%basedir%'")->one();
$this->bin = $row->Value;
$sql = $this->bin . "/bin/mysql -u" . $username . " -p" . $password . " " . trim($model->host_db) . " < " . \Yii::getAlias('@application/install.sql');
exec($sql);
}
$pwd = crypt(trim($model->password), $this->salt());
$u = $this->escap(trim($model->username));
$e = $this->escap(trim($model->email));
$sql = "INSERT INTO auth_users SET username='{$u}',email='{$e}',password='{$pwd}',active=1,created=" . time() . ",updated=" . time();
$db->query($sql);
flash('success', __('install success'));
$this->redirect(url('install/success'));
}
}
}
$data['url'] = $url;
$data['model'] = $model;
return $this->render('index', $data);
}
示例12: verEstadosPais
public static function verEstadosPais()
{
$db = new db();
$db->connect();
$query = 'SELECT * FROM lista_estados WHERE id_pais = ' . self::$id_pais;
$db->query($query);
$Arr = array();
while ($r = $db->next()) {
$Arr[] = $r;
}
$db->close();
return $Arr;
}
示例13: exists
public function exists($email, $password)
{
$query = "SELECT name,email,password FROM users WHERE email= '" . $email . "'AND password='" . $password . "'";
db::connect();
$result = db::selectquery($query);
if ($result) {
$this->name = $result[0]['name'];
}
if ($result) {
$data = $result ? $this : false;
}
return $data;
}
示例14: addVideoToDB
private function addVideoToDB($data, $playlist)
{
$db = new db();
$db->connect();
$id = $data['items'][0]['id'];
$title = mysql_real_escape_string($data['items'][0]['snippet']['title']);
$description = mysql_real_escape_string($data['items'][0]['snippet']['description']);
$thumbnail = mysql_real_escape_string($data['items'][0]['snippet']['thumbnails']['medium']['url']);
$query = "INSERT INTO videos ( id, title, description, thumbnail ) VALUES ( '{$id}' , '{$title}' , '{$description}' , '{$thumbnail}' );";
$result = mysql_query($query) or die('Could not add video.');
mysql_close();
$this::setVideoPlaylist($id, $playlist);
}
示例15: addPage
public function addPage($link, $title, $description, $feature, $content)
{
$db = new db();
$db->connect();
$link = mysql_real_escape_string($link);
$title = mysql_real_escape_string($title);
$description = mysql_real_escape_string($description);
$feature = mysql_real_escape_string($feature);
$content = mysql_real_escape_string($content);
$query = "\n\t\t\tINSERT INTO `pages`(`uid`, `link`, `title`, `description`, `feature`, `content`)\n\t\t\tVALUES (NULL, '{$link}', '{$title}', '{$description}', '{$feature}', '{$content}')";
$result = mysql_query($query) or die('Could not add page.');
mysql_close();
}