Пример #1
0
 /**
  * 设置当前数据表的元数据
  */
 protected function _setupMeta()
 {
     $table_name = $this->getFullTableName();
     $this->_cache_id = $this->_conn->getID() . '-' . $table_name;
     if (isset(self::$_meta[$this->_cache_id])) {
         return;
     }
     $cached = Q::getIni('db_meta_cached');
     if ($cached) {
         // 尝试从缓存读取
         $policy = array('encoding_filename' => true, 'serialize' => true, 'life_time' => Q::getIni('db_meta_lifetime'), 'cache_dir' => Q::getIni('runtime_cache_dir'));
         $backend = Q::getIni('db_meta_cache_backend');
         $data = Q::getCache($this->_cache_id, $policy, $backend);
         if (is_array($data) && !empty($data)) {
             self::$_meta[$this->_cache_id] = $data[0];
             self::$_fields[$this->_cache_id] = $data[1];
             return;
         }
     }
     // 从数据库获得 meta
     $meta = $this->_conn->metaColumns($table_name);
     $fields = array();
     foreach ($meta as $field) {
         $fields[$field['name']] = true;
     }
     self::$_meta[$this->_cache_id] = $meta;
     self::$_fields[$this->_cache_id] = $fields;
     $data = array($meta, $fields);
     if ($cached) {
         // 缓存数据
         Q::setCache($this->_cache_id, $data, $policy, $backend);
     }
 }
Пример #2
0
 /**
  * 构造函数
  *
  * @param QDB_Adapter_Abstract $dbo
  */
 function __construct(QDB_Adapter_Abstract $dbo)
 {
     QDebug::dump(__METHOD__);
     $this->_dbo = $dbo;
     $this->_dbo->startTrans();
     $this->_id = $dbo->getID();
     $this->_helper = new QDB_Transaction_Helper($this->_trans_failed);
 }
Пример #3
0
 function testGetID()
 {
     $id = $this->dbo->getID();
     $this->assertTrue(!empty($id));
 }