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