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


PHP static::connection方法代碼示例

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


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

示例1: connect

 private static function connect($settings)
 {
     $database = $settings['database'];
     // we do not specify the database name as it may not exist
     $config = array('driver' => 'mysql', 'hostname' => $database['host'], 'port' => $database['port'], 'username' => $database['user'], 'password' => $database['pass'], 'charset' => 'utf8');
     static::$connection = DB::factory($config);
 }
開發者ID:anchorcms,項目名稱:anchor-cms,代碼行數:7,代碼來源:installer.php

示例2: _init

 /**
  * Initialize the Redis connection object and connect to the Redis server.
  *
  * @return void
  */
 protected function _init()
 {
     if (!static::$connection) {
         static::$connection = new \Redis();
     }
     list($IP, $port) = explode(':', $this->_config['server']);
     static::$connection->connect($IP, $port);
 }
開發者ID:EHER,項目名稱:monopolis,代碼行數:13,代碼來源:Redis.php

示例3: 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

示例4: getConnection

 /**
  * @return Client
  */
 public function getConnection()
 {
     if (static::$connection === null) {
         static::$connection = Di::getDefault()->getShared('Neo4jClient');
     }
     return static::$connection;
 }
開發者ID:boorlyk,項目名稱:friendsApi,代碼行數:10,代碼來源:UsersNeo4jRepository.php

示例5: set_connection

 /**
  * Sets the database connection to use for following DBUtil calls.
  *
  * @param  string|object  string connection name or \Database_Connection object, null for default
  */
 public static function set_connection($connection, $db = null)
 {
     if (!is_string($connection) and $connection instanceof Database_Connection) {
         throw new \FuelException('A connection must be supplied as a string or a Database_Connection object.');
     }
     static::$connection = $connection;
 }
開發者ID:wushian,項目名稱:MDD,代碼行數:12,代碼來源:dbutil.php

示例6: initialize

 public static function initialize()
 {
     if (static::$connection !== NULL) {
         return;
     }
     static::$connection = new \SQLite3(__DIR__ . '/../geodb.sqlite');
 }
開發者ID:mia3,項目名稱:geodb,代碼行數:7,代碼來源:GeoDb.php

示例7: getConnection

 /**
  * @return PDO
  */
 public static function getConnection()
 {
     if (!static::$connection) {
         static::$connection = new PDO('sqlite:' . Naf::config('hamster.path_to_db'), null, null, array(PDO::ATTR_PERSISTENT => true));
     }
     return static::$connection;
 }
開發者ID:nakonechny,項目名稱:redmineUtils,代碼行數:10,代碼來源:Db.php

示例8: connection

 /**
  * Get the Memcached connection instance.
  *
  * <code>
  *		// Get the Memcache connection and get an item from the cache
  *		$name = Memcached::connection()->get('name');
  *
  *		// Get the Memcache connection and place an item in the cache
  *		Memcached::connection()->set('name', 'Taylor');
  * </code>
  *
  * @return Memcached
  */
 public static function connection()
 {
     if (is_null(static::$connection)) {
         static::$connection = static::connect(Config::get('cache.memcached'));
     }
     return static::$connection;
 }
開發者ID:bamper,項目名稱:laravel.com,代碼行數:20,代碼來源:memcached.php

示例9: __construct

 public function __construct($user, $pw, $host, $db)
 {
     if (static::$connection === null) {
         // if theres no connection
         static::$connection = mysqli_connect($host, $user, $pw, $db);
     }
 }
開發者ID:nayeonk,項目名稱:ITP-404,代碼行數:7,代碼來源:database.php

示例10: connection

 /**
  * @return \Memcached
  */
 public static function connection()
 {
     if (static::$connection === null) {
         static::$connection = static::connect(Config::get('cache.memcached.servers'));
     }
     return static::$connection;
 }
開發者ID:gjerokrsteski,項目名稱:pimf-framework,代碼行數:10,代碼來源:Memcached.php

示例11: getConnection

 public static function getConnection()
 {
     // Se a conexão não estiver feita,
     if (!static::$connection) {
         $config = Config::get('database');
         $driver = $config['driver'];
         // Buscar parametros da driver e da base de dados
         if ($driver == 'mysql') {
             try {
                 static::$connection = new \PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['database'], $config['username'], $config['password']);
                 static::$connection->setAttribute(\PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                 static::$connection_status = self::$connection->getAttribute(PDO::ATTR_CONNECTION_STATUS);
             } catch (PDOException $e) {
                 echo $e->getMessage();
                 exit;
             }
         }
         if ($driver === 'SQLite3') {
             try {
                 static::$connection = new \PDO('sqlite:' . ROOT . DS . 'app' . DS . 'files' . DS . 'database' . DS . 'databases' . DS . $config['database'] . '.sq3');
                 static::$connection_status = self::$connection->getAttribute(PDO::ATTR_CONNECTION_STATUS);
             } catch (PDOException $e) {
                 echo $e->getMessage();
                 exit;
             }
         }
     }
     return static::$connection;
 }
開發者ID:pihh,項目名稱:mariana-framework,代碼行數:29,代碼來源:database.php

示例12: set_connection

 /**
  * Sets the database connection to use for following DBUtil calls.
  *
  * @param  string  $connection  connection name, null for default
  */
 public static function set_connection($connection)
 {
     if ($connection !== null and !is_string($connection)) {
         throw new \FuelException('A connection must be supplied as a string.');
     }
     static::$connection = $connection;
 }
開發者ID:SainsburysTests,項目名稱:sainsburys,代碼行數:12,代碼來源:dbutil.php

示例13: getInstance

 /**
  * @return PDO
  */
 public static function getInstance()
 {
     if (empty(static::$connection)) {
         $config = (require $_SERVER['DOCUMENT_ROOT'] . '/lesson19-Ajax/config/database.php');
         static::$connection = new PDO($config['dsn'], $config['username'], $config['password']);
     }
     return static::$connection;
 }
開發者ID:GutsVadim,項目名稱:webseo11.dev,代碼行數:11,代碼來源:Connection.php

示例14: connection

 /**
  * @return \Memcached
  */
 public static function connection()
 {
     if (static::$connection === null) {
         $conf = Registry::get('conf');
         static::$connection = static::connect($conf['cache']['servers']);
     }
     return static::$connection;
 }
開發者ID:PermeAgility,項目名稱:FrameworkBenchmarks,代碼行數:11,代碼來源:Memcached.php

示例15: getConnection

 /**
  * Get default connection resource
  *
  * return \PDO
  */
 public function getConnection()
 {
     if (null === static::$connection) {
         $conn = static::$pool->getConnection(static::$connection_name);
         static::$connection = null === $conn->getResource() ? $conn->create() : $conn->getResource();
     }
     return static::$connection;
 }
開發者ID:ahmeti,項目名稱:php-bench,代碼行數:13,代碼來源:DbAdapterBase.php


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