當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBAdapter::db方法代碼示例

本文整理匯總了PHP中DBAdapter::db方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBAdapter::db方法的具體用法?PHP DBAdapter::db怎麽用?PHP DBAdapter::db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBAdapter的用法示例。


在下文中一共展示了DBAdapter::db方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: bind

 public static function bind($database)
 {
     // Connects DB and set environment variables
     // $database array should contain 'server','username','password'.
     self::$cachedResult = self::$dbProperties = array();
     if (!isset($database) || empty($database)) {
         return false;
     }
     if (!isset($database['port']) && strpos($database['server'], ':')) {
         $port = explode(":", $database['server']);
         $database['server'] = $port[0];
         $database['port'] = $port[1];
     }
     if (!defined('__TEXTCUBE_DATA_DIR__')) {
         define('__TEXTCUBE_DATA_DIR__', __TEXTCUBE_CACHE_DIR__);
     }
     if (!file_exists(__TEXTCUBE_DATA_DIR__)) {
         @mkdir(__TEXTCUBE_DATA_DIR__);
     }
     self::$db = new SQLite3(__TEXTCUBE_DATA_DIR__ . '/' . $database['database'] . '.sqlite', SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
     if (!self::$db) {
         return false;
     }
     return true;
 }
開發者ID:webhacking,項目名稱:Textcube,代碼行數:25,代碼來源:Adapter.php

示例2: bind

 public static function bind($database)
 {
     // Connects DB and set environment variables
     // $database array should contain 'server','username','password'.
     self::$cachedResult = self::$dbProperties = array();
     if (!isset($database) || empty($database)) {
         return false;
     }
     if (!isset($database['port']) && strpos($database['server'], ':')) {
         $port = explode(":", $database['server']);
         $database['server'] = $port[0];
         $database['port'] = $port[1];
     }
     if (isset($database['port'])) {
         self::$db = new mysqli($database['server'], $database['username'], $database['password'], $database['database'], intval($database['port']));
     } else {
         self::$db = new mysqli($database['server'], $database['username'], $database['password'], $database['database']);
     }
     if (!self::$db) {
         return false;
     }
     if (!self::$db->select_db($database['database'])) {
         die("Connection error :" . self::$db->errorno . " - " . self::$db->error);
     }
     //self::$db->autocommit(false);	// Turns off autocommit.
     self::$db->autocommit(true);
     // Turns off autocommit.
     if (self::$db->set_charset("utf8")) {
         self::$dbProperties['charset'] = 'utf8';
     } else {
         self::$dbProperties['charset'] = 'default';
     }
     @self::query('SET SESSION collation_connection = \'utf8_general_ci\'');
     return true;
 }
開發者ID:ni5am,項目名稱:Textcube,代碼行數:35,代碼來源:Adapter.php

示例3: bind

 public static function bind($database)
 {
     self::$cachedResult = self::$dbProperties = array();
     // Connects DB and set environment variables
     // $database array should contain 'server','username','password'.
     if (!isset($database) || empty($database)) {
         return false;
     }
     self::$db = @mysql_connect($database['server'] . (isset($database['port']) ? ':' . $database['port'] : ''), $database['username'], $database['password']);
     if (!self::$db) {
         return false;
     }
     self::$db = @mysql_select_db($database['database']);
     if (!self::$db) {
         return false;
     }
     if (self::query('SET CHARACTER SET utf8')) {
         self::$dbProperties['charset'] = 'utf8';
     } else {
         self::$dbProperties['charset'] = 'default';
     }
     @self::query('SET SESSION collation_connection = \'utf8_general_ci\'');
     return true;
 }
開發者ID:ragi79,項目名稱:Textcube,代碼行數:24,代碼來源:Adapter.php


注:本文中的DBAdapter::db方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。