当前位置: 首页>>代码示例>>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;未经允许,请勿转载。