当前位置: 首页>>代码示例>>PHP>>正文


PHP db::connect方法代码示例

本文整理汇总了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;
 }
开发者ID:hillmediakft,项目名称:multijob,代码行数:10,代码来源:db_class.php

示例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();
 }
开发者ID:mtaisigue,项目名称:albaranes,代码行数:25,代码来源:Pais.php

示例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;
    }
开发者ID:mtaisigue,项目名称:albaranes,代码行数:27,代码来源:Login.php

示例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;
 }
开发者ID:h3len,项目名称:Project,代码行数:30,代码来源:get_access_token.php

示例5: getTableDS

 public function getTableDS($table)
 {
     $sql = 'SELECT * FROM ' . $table . ' ORDER BY id';
     db::connect();
     $result = db::dataSource($sql);
     return $result;
 }
开发者ID:bazo,项目名称:diplomovka,代码行数:7,代码来源:TablesModel.php

示例6: _prepare

 private function _prepare()
 {
     db::connect();
     dibi::addSubst('table', 'students');
     dibi::addSubst('courses_students', 'courses_students');
     dibi::addSubst('courses', 'courses');
 }
开发者ID:bazo,项目名称:diplomovka,代码行数:7,代码来源:StudentsModel.php

示例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;
 }
开发者ID:nopp,项目名称:xenorganizer,代码行数:8,代码来源:usersManager.php

示例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();
 }
开发者ID:rolandoislas,项目名称:rolandoislas.com-php,代码行数:9,代码来源:class.updateVideo.php

示例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);
 }
开发者ID:rolandoislas,项目名称:rolandoislas.com-php,代码行数:10,代码来源:class.videoData.php

示例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);
}
开发者ID:rolandoislas,项目名称:rolandoislas.com-php,代码行数:12,代码来源:index.php

示例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);
 }
开发者ID:hiproz,项目名称:yincart2,代码行数:52,代码来源:InstallController.php

示例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;
 }
开发者ID:mtaisigue,项目名称:albaranes,代码行数:13,代码来源:Pais.php

示例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;
 }
开发者ID:kedika,项目名称:Login_Register_Example,代码行数:13,代码来源:user.php

示例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);
 }
开发者ID:rolandoislas,项目名称:rolandoislas.com-php,代码行数:13,代码来源:class.addVideo.php

示例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();
 }
开发者ID:rolandoislas,项目名称:rolandoislas.com-php,代码行数:13,代码来源:class.page.php


注:本文中的db::connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。