コード例 #1
0
ファイル: Redis.php プロジェクト: zhxia/nspf
 public function __construct($config)
 {
     $this->_redis = new \Redis();
     if (isset($config['pconnect']) && $config['pconnect']) {
         $this->_redis->pconnect($config['host'], $config['port'], $config['timeout']);
     } else {
         $this->_redis->connect($config['host'], $config['port'], $config['timeout']);
     }
     $this->_debugger = Debugger::getInstance();
 }
コード例 #2
0
ファイル: Memcached.php プロジェクト: zhxia/nspf
 public function __construct($config)
 {
     if ($config && is_array($config)) {
         $this->_memcached = new \Memcached();
         foreach ($config as $val) {
             $this->_memcached->addServer($val['host'], $val['port'], $val['weight']);
         }
         $this->_debugger = Debugger::getInstance();
     } else {
         trigger_error('Memcached config is empty!');
     }
 }
コード例 #3
0
ファイル: Pdo.php プロジェクト: zhxia/nspf
 /**
  * @param string $statement
  * @param null $pdo_option
  * @param null $object
  * @return PDOStatement
  */
 public function query($statement, $pdo_option = null, $object = null)
 {
     Debugger::getInstance()->debug('SQL:' . $statement);
     if ($pdo_option != null && $object != null) {
         $stmt = parent::query($statement, $pdo_option, $object);
     } else {
         $stmt = parent::query($statement);
     }
     if ($stmt instanceof PDOStatement) {
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
     }
     return $stmt;
 }
コード例 #4
0
ファイル: Statement.php プロジェクト: zhxia/nspf
 public function execute($inputParameters = array())
 {
     $ret = parent::execute($inputParameters);
     Debugger::getInstance()->debug('SQL:' . $this->queryString . ';params:' . var_export($inputParameters, true));
     if (!$ret) {
         $error_info = parent::errorInfo();
         if (parent::errorCode() != '00000') {
             // 执行成功时返回五个零
             LoggerFactory::getLogger()->error('PDO executed failed,errors:' . var_export($error_info, true));
             trigger_error($this->queryString, E_USER_ERROR);
         }
     }
     return $ret;
 }
コード例 #5
0
ファイル: Statement.php プロジェクト: zhxia/nspf
 public function prepare($query)
 {
     Debugger::getInstance()->debug('SQL:' . $query);
     return parent::prepare($query);
 }
コード例 #6
0
ファイル: Mysqli.php プロジェクト: zhxia/nspf
 /**
  * @param string $query
  * @return Statement
  */
 public function prepare($query)
 {
     Debugger::getInstance()->debug('SQL:' . $query);
     return new Statement($this, $query);
 }