params['mongodb']; $mongo_server = $mongo['server']; $mongo_db = $mongo['db']; try { // if(class_exists('MongoClient')){ // self::$mongo_obj = new MongoClient($mongo_server); // }else{ // } self::$mongo_obj = new Mongo($mongo_server); $collection=self::$mongo_obj->selectCollection($mongo_db,$table_name); if (isset($other_pra['fields']) && $other_pra['fields']) { $fields = $other_pra['fields']; }else{ $fields = array(); } if (isset($other_pra['sort']) && $other_pra['sort']) { $sort = $other_pra['sort']; }else{ $sort = array(); } if (isset($other_pra['limit']) && $other_pra['limit']) { $limit = $other_pra['limit']; }else{ $limit = array(); } //返回数据是否重建索引 if (isset($other_pra['is_index'])) { $is_index = $other_pra['is_index']; }else{ $is_index = true; } $cursor = $collection->find($params,$fields); if($sort){ $cursor->sort($sort); } if($limit){ $cursor->limit($limit); } if($cursor){ $res = iterator_to_array($cursor); } self::close(); if($res && is_array($res)){ if ($is_index) { $_res = $res; $res = array(); foreach ($_res as $re) { $res[$re['_id']] = $re; } } unset($_res); } } catch (Exception $ex) { exit($ex->getMessage()); } return $res; } static public function close() { if (self::$mongo_obj) { self::$mongo_obj->close(); } } }