/**
  * dump 结果
  * @param bool $toObject 转换为实体;
  * @return array
  * @throws
  */
 public function _array($toObject = true)
 {
     if ($this->tableIns == null) {
         try {
             $mongoManager = \my\bq\mdbao\MongoManager::getInstance();
             $this->mongoDatabase = $mongoManager->getDatabase($this->tableEntity);
         } catch (MongoConnectionException $e) {
             throw $e;
         }
     }
     $parmas = $this->getParameters();
     $order = $this->getOrderQuery();
     $cursor = null;
     //fields;
     $fields = $this->getFileds();
     $fetchFields = null;
     if (!($fields && $fields[0] == "*")) {
         if (is_array($fields)) {
             foreach ($fields as $k => $field) {
                 unset($fields[$k]);
                 if (is_object($field)) {
                     $fields[$field->getPropertyName()] = true;
                 } else {
                     $fields[$field] = true;
                 }
             }
             $fetchFields = $fields;
         }
     }
     if (Configuration::$SHOW_MONGO_QUERY) {
         $_Lginfo = array('query' => $parmas);
         if ($order) {
             $_Lginfo['order'] = $order;
         }
         if ($this->fetchSize > 0) {
             $_Lginfo['skip'] = array($this->firstResult, $this->fetchSize);
         }
         if ($fetchFields != null) {
             $_Lginfo['fields'] = array($fetchFields);
         }
         Log::writeMsg(Log::NOTICE, "MongoQuery SEARCH :[" . $this->table . "]  " . var_export($_Lginfo, true));
     }
     if ($this->modifier != null) {
         $cursor = $this->mongoDatabase->command(array('findandmodify' => $this->table, 'query' => $parmas, 'update' => $this->modifier));
         if ($cursor['lastErrorObject']['err'] != null) {
             Log::writeMsg(Log::ERROR, "MongoERR:[" . $this->table . "]" . var_export($cursor['lastErrorObject'], true));
             throw new \Exception($cursor['lastErrorObject']['err'], $cursor['lastErrorObject']['code']);
         }
     } else {
         $this->tableIns = $this->mongoDatabase->selectCollection($this->table);
         $cursor = $this->tableIns->find($parmas);
     }
     //has order
     if (is_array($order) && count($order) > 0) {
         $cursor->sort($order);
     }
     //has limit
     if ($this->fetchSize > 0) {
         $cursor->skip($this->firstResult)->limit($this->fetchSize);
     }
     //fields;
     if ($fetchFields != null) {
         $cursor->fields($fetchFields);
     }
     $dataArray = array();
     foreach ($cursor as $cur) {
         if (!$cur['_id']) {
             continue;
         }
         $d = array();
         $d['_id'] = $cur['_id'];
         if ($fields && $fields[0] == "*") {
             $this->fileds = $this->columns;
         }
         foreach ($this->fileds as $filed) {
             if (is_object($filed)) {
                 $f = explode('.', $filed->getPropertyName());
                 if (is_array($f)) {
                     $v = $cur[$f[0]];
                     unset($f[0]);
                     foreach ($f as $i) {
                         $v = $v[$i];
                     }
                     $d[$filed->getAlias()] = $v;
                 }
             } else {
                 $d[$filed] = $cur[$filed];
             }
         }
         $dataArray[] = $d;
     }
     if ($toObject) {
         $cache = CacheManager::getInstance();
         $tableEntitys = $cache->get('tableEntity');
         if (!$tableEntitys) {
             $tableEntitys = array($this->tableEntity);
         }
         $transData = $this->translaters;
         if (is_array($transData) && $transData[0]) {
             foreach ($dataArray as $k => $data) {
                 foreach ($transData as $dataTranslater) {
                     $property = $dataTranslater->getProperty();
                     if (!isset($data[$property->getPropertyName()])) {
                         break;
                     }
                     $value = $data[$property->getPropertyName()];
                     if ($value) {
                         $data[$property->getAlias()] = $dataTranslater->translate($value);
                         $dataArray[$k] = $data;
                     }
                 }
             }
         }
         if ($tableEntitys) {
             foreach ($dataArray as $k => $data) {
                 //if(Relation::$hasRelation) //has relation
                 //to object
                 $dataArray[$k] = $this->dataToObject($tableEntitys, $data);
             }
         }
     }
     Relation::$hasRelation = false;
     CacheManager::getInstance()->clean();
     return $dataArray;
 }
 public function _array($toObject = true)
 {
     $pdoManager = PdoManager::getInstance();
     $pdo = $pdoManager->getPdo($this->tableEntity);
     $sql = $this->sql();
     $parmas = $this->getParameters();
     $dataArray = $pdo->getRows($sql, $parmas);
     if ($toObject) {
         $cache = CacheManager::getInstance();
         $tableEntitys = $cache->get('tableEntity');
         if (!$tableEntitys) {
             $tableEntitys = array($this->tableEntity);
         }
         $transData = $this->getRootAndJoinsTranslater();
         if (is_array($transData) && $transData[0]) {
             foreach ($dataArray as $k => $data) {
                 foreach ($transData as $dataTranslater) {
                     if ($dataTranslater) {
                         $property = $dataTranslater->getProperty();
                         $dataKey = $this->getAlias() . "__" . $property->getPropertyName();
                         if (!array_key_exists($dataKey, $data)) {
                             continue;
                         }
                         $data[$this->getAlias() . "__" . $property->getAlias()] = $dataTranslater->translate($data[$dataKey]);
                         $dataArray[$k] = $data;
                     }
                 }
             }
         }
         if ($tableEntitys) {
             foreach ($dataArray as $k => $data) {
                 //if(Relation::$hasRelation) //has relation
                 //to object
                 $dataArray[$k] = $this->dataToObject($tableEntitys, $data);
             }
         }
     }
     Relation::$hasRelation = false;
     CacheManager::getInstance()->clean();
     return $dataArray;
 }