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


PHP static::db方法代碼示例

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


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

示例1: connect

 public static function connect($db)
 {
     $uri = 'mongodb://something';
     $mongo = new MongoClient($uri, ['username' => 'user', 'password' => 'password', 'ssl' => true, 'w' => true]);
     static::$db = $mongo->{$db};
     static::$connection = $mongo;
     static::$isConnected = static::$connection->connected;
 }
開發者ID:BenPaster,項目名稱:php-base-app,代碼行數:8,代碼來源:Database.php

示例2: set_up

 public function set_up($connection_name = null)
 {
     ActiveRecord\Table::clear_cache();
     $config = ActiveRecord\Config::instance();
     $this->original_default_connection = $config->get_default_connection();
     $this->original_date_class = $config->get_date_class();
     if ($connection_name) {
         $config->set_default_connection($connection_name);
     }
     if ($connection_name == 'sqlite' || $config->get_default_connection() == 'sqlite') {
         // need to create the db. the adapter specifically does not create it for us.
         static::$db = substr(ActiveRecord\Config::instance()->get_connection('sqlite'), 9);
         new SQLite3(static::$db);
     }
     $this->connection_name = $connection_name;
     try {
         $this->conn = ActiveRecord\ConnectionManager::get_connection($connection_name);
     } catch (ActiveRecord\DatabaseException $e) {
         $this->mark_test_skipped($connection_name . ' failed to connect. ' . $e->getMessage());
     }
     $GLOBALS['ACTIVERECORD_LOG'] = false;
     $loader = new DatabaseLoader($this->conn);
     $loader->reset_table_data();
     if (self::$log) {
         $GLOBALS['ACTIVERECORD_LOG'] = true;
     }
 }
開發者ID:visavi,項目名稱:phpactiverecord,代碼行數:27,代碼來源:DatabaseTest.php

示例3: DB

 /** @return DB */
 public static function DB()
 {
     if (is_null(static::$db)) {
         static::$db = new DB(static::GetConnection(), PREFIX);
     }
     return static::$db;
 }
開發者ID:cmsx,項目名稱:fw,代碼行數:8,代碼來源:X.php

示例4: init

 protected static function init()
 {
     if (!empty(static::$db)) {
         return;
     }
     static::$db = classSupernova::$db;
 }
開發者ID:divyinfo,項目名稱:SuperNova,代碼行數:7,代碼來源:PlayerToAccountTranslate.php

示例5: getManager

 function getManager()
 {
     if (is_null(static::$db)) {
         static::$db = makeDB();
     }
     return static::$db;
 }
開發者ID:cmsx,項目名稱:navigator,代碼行數:7,代碼來源:init.php

示例6: connect

 public static function connect()
 {
     if (!self::$con) {
         static::$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
         static::$db = mysql_select_db(DB_NAME, self::$con) or die("Failed to connect to mysql:" . mysql_errno());
     }
 }
開發者ID:kedika,項目名稱:Login_Register_Example,代碼行數:7,代碼來源:db.php

示例7: catch

 /**
  *  constructor
  *  @param  mixed   param   PDO instance,
  *                          or record id (if integer),
  *                          or constraints (if array) but param['pdo'] is PDO instance
  */
 function __construct($params = null)
 {
     try {
         if (!static::$db && static::$adapter) {
             static::$db = new static::$adapter(static::$db_settings);
         }
     } catch (Exception $e) {
         throw new WaxDbException("Cannot Initialise DB", "Database Configuration Error");
     }
     $class_name = get_class($this);
     if ($class_name != 'WaxModel' && !$this->table) {
         $this->table = Inflections::underscore($class_name);
     }
     $this->define($this->primary_key, $this->primary_type, $this->primary_options);
     $this->setup();
     $this->set_identifier();
     // If a scope is passed into the constructor run a method called scope_[scope]().
     if ($params) {
         $method = "scope_" . $params;
         if (method_exists($this, $method)) {
             $this->{$method};
         } else {
             $res = $this->filter(array($this->primary_key => $params))->first();
             $this->row = $res->row;
             $this->clear();
         }
     }
 }
開發者ID:phpwax,項目名稱:waxmodel,代碼行數:34,代碼來源:WaxModel.php

示例8: __construct

 /**
  * Constructor.
  * 
  * @param \wpdb $db
  */
 public function __construct(wpdb $db)
 {
     if (!isset(static::$instance)) {
         static::$instance = $this;
         static::$db = $db;
     }
 }
開發者ID:wells5609,項目名稱:wp-app,代碼行數:12,代碼來源:Connection.php

示例9: init

 /** 
  * Main function for initialize this class.
  * @param \Slim\Slim
  */
 public static function init()
 {
     date_default_timezone_set(static::config()->timezone);
     static::$db = static::config()->db;
     static::$user = new \ptejada\uFlex\User();
     static::$app = new \Slim\Slim();
     static::$mail = new \PHPMailer();
     static::$assets = new \Assets();
     static::$user->config->database->host = static::config()->db['server'];
     static::$user->config->database->user = static::config()->db['username'];
     static::$user->config->database->password = static::config()->db['password'];
     static::$user->config->database->name = static::config()->db['database_name'];
     static::$user->start();
     require 'app/config/mail.php';
     static::$mail->isSMTP();
     static::$mail->Host = $mail['Host'];
     static::$mail->SMTPAuth = $mail['SMTPAuth'];
     static::$mail->Username = $mail['Username'];
     static::$mail->Password = $mail['Password'];
     static::$mail->SMTPSecure = $mail['SMTPSecure'];
     static::$mail->Port = $mail['Port'];
     static::$mail->From = $mail['From'];
     static::$mail->FromName = $mail['FromName'];
     static::$mail->isHTML(true);
 }
開發者ID:mgilangjanuar,項目名稱:slimedoo,代碼行數:29,代碼來源:App.php

示例10: connect

 public static function connect()
 {
     if (is_null(static::$db)) {
         static::$db = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     }
     return static::$db;
 }
開發者ID:nathanharper,項目名稱:glibreviews,代碼行數:7,代碼來源:nSQL.php

示例11: __construct

 public function __construct()
 {
     static::$instance = $this;
     if (!isset(static::$db)) {
         static::$db = new DatabaseConnect();
     }
 }
開發者ID:henryngoo,項目名稱:magictest,代碼行數:7,代碼來源:User.php

示例12: getInstance

 /**
  * Returns the *Singleton* instance of this class.
  *
  * @return Factory the singleton instance.
  */
 public static function getInstance()
 {
     if (null === static::$instance) {
         static::$instance = new static();
         static::$db = \Xoops::getInstance()->db();
     }
     return static::$instance;
 }
開發者ID:ming-hai,項目名稱:XoopsCore,代碼行數:13,代碼來源:Factory.php

示例13: getDbConnection

 /**
  * 返回active record使用的數據庫連接。
  * 默認使用'db'應用組件作為數據庫連接。
  * 如果你想使用不同的數據庫連接的話你可以重寫該方法。
  * @return ConnectionPool active record使用的數據庫連接。
  */
 public static function getDbConnection()
 {
     if (static::$db !== null) {
         return static::$db;
     } else {
         return static::$db = \Sky\Sky::$app->getDb();
     }
 }
開發者ID:jymsy,項目名稱:sky2,代碼行數:14,代碼來源:ActiveRecord.php

示例14: getDb

 /**
  * Returns new cmysql class for custom SQL querying, based on current database connection
  * @return cMySql
  */
 public static function getDb($fresh = false)
 {
     if ($fresh || !isset(self::$db)) {
         static::$db = new MySQL(static::connect());
         return static::$db;
     }
     return static::$db;
 }
開發者ID:tiger154,項目名稱:prototype,代碼行數:12,代碼來源:Core.php

示例15: getDbConnection

 /**
  * getDbConnection return current DB connection or create new if not exist
  * 
  * @return type
  */
 static function getDbConnection()
 {
     if (empty(static::$db)) {
         $pdo = Service::get('pdo');
         static::$db = new \PDO($pdo['dns'], $pdo['user'], $pdo['password']);
     }
     return static::$db;
 }
開發者ID:steemd,項目名稱:framework,代碼行數:13,代碼來源:ActiveRecord.php


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