/**
  * 数据设置器
  * 会自动标记脏数据
  *
  * @param string $key
  * @param mixed $value
  * @return boolean
  */
 protected function D_setter($key, $value)
 {
     $key = strval($key);
     // mongodb主键
     if ($key == self::DBKey_dbid) {
         $this->set_dbid($value);
         return true;
     }
     // functionsDump ( $this->is_exist_DBId () );
     // dump_stack ();
     // functionsDump ( $this->_loading_data );
     // assert ( false, 0 );
     if (!$this->_loading_data) {
         // 不是从db加载数据
         // 只读数据
         if ($this->is_readonly()) {
             // 实际上问题不大.因为在使用只读数据的时候,也可以参与运算.但是不会赋值
             // 在需要真实数据的时候,应该还会使用用户主体数据的
             // CommonUtilLog::record ( CommonUtilLog::ERROR, 'set_readonly_db', [
             // 'tablename' => $this->get_tablename (),
             // 'dbkey' => $key,
             // 'oldvalue' => $this->getdata ( $key ),
             // 'newvalue' => $value,
             // 'stack' => dump_stack ( true )
             // ] );
         }
         if (C(Config::DEBUG)) {
             $checkret = DBMongo::check_data_error($value);
             if ($checkret != DBMongo::CHECK_DATA_RETCODE_SUCC) {
                 dump("errorset:" . $key);
                 dump_stack();
                 dump($value, true);
                 return false;
             }
         }
         $oldValue = $this->getdata($key);
         if (!is_array($value) && $oldValue === $value) {
             return true;
         }
         if (C(Config::DEBUG_DB)) {
             $this->mark_dirty($key, $oldValue, $value);
         } else {
             $this->mark_dirty();
         }
     }
     $this->_data_contains[$key] = $value;
     return TRUE;
 }
Exemple #2
0
 /**
  * 默认数据池
  *
  * @return DBPools
  */
 public static function default_Db_pools()
 {
     if (!self::$_default_instance instanceof self) {
         $db_ins = new DBMongo(C(Constants::Const_DB_Connection));
         $db_ins->selectDB(C(Constants::Const_DB_Name));
         self::$_default_instance = self::create($db_ins);
     }
     return self::$_default_instance;
 }