当前位置: 首页>>代码示例>>PHP>>正文


PHP static::_db方法代码示例

本文整理汇总了PHP中static::_db方法的典型用法代码示例。如果您正苦于以下问题:PHP static::_db方法的具体用法?PHP static::_db怎么用?PHP static::_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在static的用法示例。


在下文中一共展示了static::_db方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getConnection

 /**
  * Create the Memcached connection
  *
  * @return  void
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 protected function getConnection()
 {
     if (!static::isSupported()) {
         throw new RuntimeException('Memcached Extension is not available');
     }
     $config = JFactory::getConfig();
     $host = $config->get('memcached_server_host', 'localhost');
     $port = $config->get('memcached_server_port', 11211);
     // Create the memcached connection
     if ($config->get('memcached_persist', true)) {
         static::$_db = new Memcached($this->_hash);
         $servers = static::$_db->getServerList();
         if ($servers && ($servers[0]['host'] != $host || $servers[0]['port'] != $port)) {
             static::$_db->resetServerList();
             $servers = array();
         }
         if (!$servers) {
             static::$_db->addServer($host, $port);
         }
     } else {
         static::$_db = new Memcached();
         static::$_db->addServer($host, $port);
     }
     static::$_db->setOption(Memcached::OPT_COMPRESSION, $this->_compress);
     $stats = static::$_db->getStats();
     $result = !empty($stats["{$host}:{$port}"]) && $stats["{$host}:{$port}"]['pid'] > 0;
     if (!$result) {
         // Null out the connection to inform the constructor it will need to attempt to connect if this class is instantiated again
         static::$_db = null;
         throw new JCacheExceptionConnecting('Could not connect to memcached server');
     }
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:40,代码来源:memcached.php

示例2: setDb

 /**
  * Set Database & Collection 设置数据库和表单
  *
  * @param array $db
  * @param number $collection
  * @return
  */
 public static function setDb($db = null, $collection = null)
 {
     if ($db && $collection) {
         static::$_db = $db;
         static::$_collection = $collection;
         self::$_mongoDB = null;
     }
 }
开发者ID:Birjemin,项目名称:Cmd_library,代码行数:15,代码来源:mongodbTool.php

示例3: _disconnect

 /**
  * 切断
  */
 protected static function _disconnect()
 {
     if (!static::$_db->close()) {
         throw new SqliteException(static::$_db->lastErrorMsg(), static::$_db->lastErrorCode());
     }
     static::$_db = null;
     return true;
 }
开发者ID:fujicat,项目名称:sardine,代码行数:11,代码来源:Sqlite.php

示例4: _disconnect

 /**
  * 切断
  */
 protected static function _disconnect()
 {
     if (!\mysql_close(static::$_db)) {
         throw new MysqlException(\mysql_error(static::$_db), \mysql_errno(static::$_db));
     }
     static::$_db = null;
     return true;
 }
开发者ID:fujicat,项目名称:sardine,代码行数:11,代码来源:Mysql.php

示例5: _disconnect

 /**
  * 切断
  */
 protected static function _disconnect()
 {
     if (!static::$_db->close()) {
         throw new MysqliException(static::$_db->error, static::$_db->errno);
     }
     static::$_db = null;
     return true;
 }
开发者ID:fujicat,项目名称:sardine,代码行数:11,代码来源:Mysqli.php

示例6: getInstance

 /**
  * Get the instance of the PDO connection
  *
  * @return DB  PDO connection
  */
 public static function getInstance()
 {
     if (static::$_db === NULL) {
         $dsn = 'mysql:host=' . Config::DB_HOST . ';dbname=' . Config::DB_NAME . ';charset=utf8';
         static::$_db = new PDO($dsn, Config::DB_USER, Config::DB_PASS);
         // Raise exceptions when a database exception occurs
         static::$_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     }
     return static::$_db;
 }
开发者ID:priom,项目名称:SobeyForStudents,代码行数:15,代码来源:Database.class.php

示例7: getConnection

 /**
  * Create the Memcache connection
  *
  * @return  void
  *
  * @since   11.1
  * @throws  RuntimeException
  */
 protected function getConnection()
 {
     $config = JFactory::getConfig();
     $this->_persistent = $config->get('memcache_persist', true);
     $this->_compress = $config->get('memcache_compress', false) == false ? 0 : MEMCACHE_COMPRESSED;
     // Create the memcache connection
     static::$_db = new Memcache();
     static::$_db->addserver($config->get('memcache_server_host', 'localhost'), $config->get('memcache_server_port', 11211), $this->_persistent);
     $memcachetest = @static::$_db->connect($server['host'], $server['port']);
     if ($memcachetest == false) {
         throw new RuntimeException('Could not connect to memcache server', 404);
     }
     // Memcahed has no list keys, we do our own accounting, initialise key index
     if (static::$_db->get($this->_hash . '-index') === false) {
         static::$_db->set($this->_hash . '-index', array(), $this->_compress, 0);
     }
     return;
 }
开发者ID:N6REJ,项目名称:joomla-cms,代码行数:26,代码来源:memcache.php

示例8: getConnection

 /**
  * Create the Memcached connection
  *
  * @return  void
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 protected function getConnection()
 {
     $config = JFactory::getConfig();
     $this->_persistent = $config->get('memcached_persist', true);
     $this->_compress = $config->get('memcached_compress', false) == false ? 0 : Memcached::OPT_COMPRESSION;
     // Create the memcache connection
     if ($this->_persistent) {
         static::$_db = new Memcached(JFactory::getSession()->getId());
     } else {
         static::$_db = new Memcached();
     }
     $memcachedtest = static::$_db->addServer($config->get('memcached_server_host', 'localhost'), $config->get('memcached_server_port', 11211));
     if ($memcachedtest == false) {
         throw new RuntimeException('Could not connect to memcached server', 404);
     }
     static::$_db->setOption(Memcached::OPT_COMPRESSION, $this->_compress);
     // Memcached has no list keys, we do our own accounting, initialise key index
     if (static::$_db->get($this->_hash . '-index') === false) {
         static::$_db->set($this->_hash . '-index', array(), 0);
     }
 }
开发者ID:kshitijSharma2014,项目名称:joomla-cms,代码行数:29,代码来源:memcached.php

示例9: getConnection

 /**
  * Create the Memcache connection
  *
  * @return  void
  *
  * @since   11.1
  * @throws  RuntimeException
  */
 protected function getConnection()
 {
     if (!static::isSupported()) {
         throw new RuntimeException('Memcache Extension is not available');
     }
     $config = JFactory::getConfig();
     $host = $config->get('memcache_server_host', 'localhost');
     $port = $config->get('memcache_server_port', 11211);
     // Create the memcache connection
     static::$_db = new Memcache();
     if ($config->get('memcache_persist', true)) {
         $result = @static::$_db->pconnect($host, $port);
     } else {
         $result = @static::$_db->connect($host, $port);
     }
     if (!$result) {
         // Null out the connection to inform the constructor it will need to attempt to connect if this class is instantiated again
         static::$_db = null;
         throw new JCacheExceptionConnecting('Could not connect to memcache server');
     }
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:29,代码来源:memcache.php

示例10: _disconnect

 /**
  * 切断
  */
 protected static function _disconnect()
 {
     static::$_db = null;
     return true;
 }
开发者ID:fujicat,项目名称:sardine,代码行数:8,代码来源:Pdo.php

示例11: __construct

 public function __construct()
 {
     static::$_db = Registry::get("db");
 }
开发者ID:sophie-vert,项目名称:api.rozklad.org.ua,代码行数:4,代码来源:Model.php

示例12: resetAllStaticPropertiesExceptDefaultConfig

 /**
  * 
  * DBConnector::resetAllStaticPropertiesExceptDefaultConfig() resets all properties
  * DBConnector::resetAllStaticPropertiesExceptDefaultConfig('_db') will reset only DBConnector::$_db
  * 
  * @param string $prop_name name of the property (eg. 'db' or '_db') whose value is to be reset. 
  * 
  */
 public static function resetAllStaticPropertiesExceptDefaultConfig($prop_name = '')
 {
     switch ($prop_name) {
         case '_config':
         case 'config':
             // Map of configuration settings
             static::$_config = array();
             break;
         case '_db':
         case 'db':
             // Map of database connections, instances of the PDO class
             static::$_db = array();
             break;
         case '_last_query':
         case 'last_query':
             // Last query run, only populated if logging is enabled
             static::$_last_query = '';
             break;
         case '_query_log':
         case 'query_log':
             // Log of all queries run, mapped by connection key, only populated if logging is enabled
             static::$_query_log = array();
             break;
         default:
             //////////////////////////
             // Reset all properties //
             //////////////////////////
             // Map of configuration settings
             static::$_config = array();
             // Map of database connections, instances of the PDO class
             static::$_db = array();
             // Last query run, only populated if logging is enabled
             static::$_last_query = '';
             // Log of all queries run, mapped by connection key, only populated if logging is enabled
             static::$_query_log = array();
             break;
     }
 }
开发者ID:rotexsoft,项目名称:leanorm,代码行数:46,代码来源:DBConnector.php

示例13: _setupDatabaseAdapter

 /**
  * Initialize database adapter.
  *
  * @return void
  */
 protected static function _setupDatabaseAdapter()
 {
     if (!static::$_db) {
         static::$_db = self::getDefaultAdapter();
         if (!static::$_db instanceof Adapter) {
             //require_once 'Zend/Db/Table/Exception.php';
             throw new DataObjectException('No adapter found for ' . get_called_class());
         }
     }
 }
开发者ID:shen2,项目名称:mypdo,代码行数:15,代码来源:DataObject.php

示例14: reset_db

 /**
  * Delete all registered PDO objects in _db array.
  */
 public static function reset_db()
 {
     static::$_db = array();
 }
开发者ID:voku,项目名称:idiorm,代码行数:7,代码来源:ORM.php

示例15: init

 static function init()
 {
     static::$_config = (include_once __DIR__ . "/../config.php");
     static::$_db = getDb(static::$_config);
 }
开发者ID:acyuta,项目名称:simple_php_api_net,代码行数:5,代码来源:logic.php


注:本文中的static::_db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。