-
- /*
- * ? ???? ????? ?? | ???
- * ????? ???? ???.
- */
-
-
- class mongo_db {
-
- private $config;
- ??? $connection;
- ??? $db;
- ??? $connection_string;
- ??? $host;
- ??? $port;
- ?? $user;
- ??? $pass;
- ??? $dbname;
- ??? $persist;
- ??? $persist_key;
- ??? $selects = array();
- ??? $wheres = array();
- ??? $sorts = array();
- ??? $limit = 999999;
- ??? $offset = 0;
- ??? $timeout = 200;
- ?? $key = 0;
- /*** ------------------------------------------------- ------------------ * ??? * --- ------------------------------------- -------------- * * Mongo PECL ??? ??/??????? ???? ?????. * ?? ???? ???? MongoDB? ?? ??? ?????.*/
-
- ?? ?? __construct() {
- if((IS_NOSQL != 1)){
- return;
- }
- if (!class_exists('Mongo')) {
- //$this->error("MongoDB PECL ??? ???? ???? ????? ?????.", 500);
- }
- $configs =wxcity_base::load_config("??","mongo_db");
- $num = count($configs['connect']);
- $this->timeout = Trim($configs['timeout']);
- $keys = wxcity_base::load_config('double');
- $this->key = $keys['mongo_db'];
- $this->config = $configs['connect'][$this->key];
- $status = $this->connect();
- if($status == false)
- {
- for($i = 1; $i < $num; $i )
- {
- $n = $this-> ? $i;
- $key = $n >= $num ? $n - $?? : $n;
- $this->config = $configs['connect'][$key];
- $status = $this->connect();
- if($status!=false)
- {
- $keys['mongo_db'] = $key ;
- $this->key = $key;
- $data = "";
- file_put_contents(WHTY_PATH.'configs/double.php', $data, LOCK_EX);
- ??;
- }
- }
- }
- if($status==false)
- {
- die('mongoDB? ???? ??');
- }
- }
-
- function __destruct() {
- if((IS_NOSQL != 1)){
- return;
- }
- if($this->connection)
- {
- $this->connection->close();
- }
- }
-
- /*** ------------------------------------------------- ------------------ * MONGODB? ?? * -------------- ------------------------------------- ---------------- * * * Connection_string() ????? ??? ?? ???? ???? MongoDB? ?? ??? ?????. * ?? ???? 'mongo_persist_key'? true? ??? ?? ?? ??? ?????. ?? ??? ????? ?? ??? 'persist' * ??? ????? ?????.*/
- private function connect() {
- $this->connection_string();
- $options = array('connect'=>true,'timeout'=>$this->timeout);
- try {
- $this->connection = new Mongo($this->connection_string, $options);
- $this->db = $this->connection->{$this->dbname};
- return($this);
- } catch(MongoConnectionException $e) {
- return false;
- }
-
- }
- /*** ------------------------------------------------- ------------------ * ?? ??? ?? * -------------- ------------------------------------- ---------------- * * ?? ???? ?? ???? ?????.*/
- private function Connection_string() {
- $this->host = Trim($this->config['hostname']);
- $this->port = Trim($this->config['port']);
- $this->user = Trim($this->config['username']);
- $this->pass = Trim($this->config['password']);
- $this->dbname = Trim($this->config['database']);
- $this->persist = Trim($this->config['autoconnect']);
- $this->persist_key = Trim($this->config['mongo_persist_key']);
-
- $connection_string = "mongodb://";
- if (emptyempty($this->host)) {
- $this->error("MongoDB? ????? ???? ???? ???.", 500);
- } if (emptyempty($this->dbname)) {
- $this->error("MongoDB? ????? ??????? ???? ???.", 500);
- } if (!emptyempty($this->user) && !emptyempty($this->pass)) {
- $connection_string .= "{$this->user}:{$this- >??}@";
- } if (isset($this->port) && !emptyempty($this->port)) {
- $connection_string .= "{$this->host}:{$this-> ;??}";
- } else {
- $connection_string .= "{$this->host}";
- } $this->connection_string = ??($connection_string);
- }
-
- /*** ------------------------------------------------- ------------------ * Switch_db * --- ------------------------------------- -------------- * * ?? ???????? ?? ??????? ??*/
- public function switch_db($database = '') {
- if (emptyempty($database)) {
- $this- >error("MongoDB ??????? ????? ? ?????? ??? ???? ???.", 500);
- } $this->dbname = $database;
- try {
- $this->db = $this->connection->{$this->dbname};
- ??(TRUE);
- } catch (Exception $e) {
- $this->error("Mongo ??????? ??? ? ????: {$e->getMessage()}", 500);
- }
- }
-
- /*** ------------------------------------------------- ------------------ * ?? ?? * --------------- ------------------------------------- --------------- * * ?? ???? ?? ??? ?? ?? ??? ??? ?????. * ??? ??? ??? ??? ??? ? ???? * $includes ??? $excludes ???? ?????. * ??? ??? ????? $includes? ? ??()? ?? ????. * * @usage: $this->mongo_db->select(array('foo', 'bar'))->get('foobar');*/
- ?? ?? select($includes = array(), $excludes = array()) {
- if (! is_array($includes)) {
- $includes = ??();
- }
- if (!is_array($excludes)) {
- $excludes = array();
- }
- if (!emptyempty($includes)) {
- foreach ($includes as $col) {
- $this->selects[$col] = 1;
- }
- } else {
- foreach ($excludes as $col) {
- $this->selects[$col] = 0;
- }
- } return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * ????? ?? * --------------- ------------------------------------- --------------- * * ??? ?? ????? ???? ??? ?????. $wheres ??? ??? ??, ?? ?? ???? * ?? ????? ???. * * @usage = $this->mongo_db->where(array('foo' => 'bar'))->get('foobar');*/
- ?? ?? where($wheres = array()) {
- foreach ((array)$wheres as $wh => $ val) {
- $this->wheres[$wh] = $val;
- } return($this);
- }
-
- /*** ------------------------------------------------- ------------------------------- * WHERE_IN 參數(shù) * --------------- -------------------------------------------------- --------------- * * 取得給定$in array() 中$field 的值所在的文件。 * * @usage = $this->mongo_db->where_in('foo', array('bar', 'zoo', 'blah'))->get('foobar');*/
- public function where_in($field = "", $in = array()) {
- $this->where_init($field);
- $this->wheres[$field]['$in'] = $in;
- 返回($this);
- }
-
- /*** ------------------------------------------------- ------------------------------- * WHERE_NOT_IN 參數(shù) * --------------- --- ----------------------------------------------- --- --------------- * * 取得$field 的值不在給定$in array() 中的文件。 * * @usage = $this->mongo_db->where_not_in('foo', array('bar', 'zoo', 'blah'))->get('foobar');*/
- public function where_not_in($field = "", $in = array()) {
- $this->where_init($現(xiàn)場);
- $this->wheres[$field]['$nin'] = $in;
- 回傳($this); }
-
- /*** ------------------------------------------------- ------------------------------- * 大於參數(shù) * ------------- -- ------------------------------------------------ -- --------------- * * 取得$field的值大於$x的文檔* * @usage = $this->mongo_db->where_gt( '富', 20);* /
- public function where_gt($field = "", $x) {
- $this->where_init($field);
- $this->wheres[$field]['$gt'] = $x;
- 回傳($this)
- }
-
- /*** ------------------------------------------------- ------------------------------- * 大於或等於參數(shù) * ---------- --- ----------------------------------------------- --- ----------------- * * 取得$field的值大於等於$x的文件* * @usage = $this-> mongo_db->where_gte('foo', 20) ;*/
- public function where_gte($field = "", $x) {
- $this-> where_init($field);
- $this->wheres[$field]['$gte'] = $x;
- 回傳($this)
- }
-
- /*** ------------------------------------------------- ------------------------------- * 小於參數(shù)的地方 * ------------- -------------------------------------------------- ----------------- * * 取得$field的值小於$x的文檔* * @usage = $this->mongo_db->where_lt( '富', 20);*/
- public function where_lt($field = "", $x) {
- $this->where_init($field);
- $this->wheres[$field ]['$lt '] = $x;
- 回傳($this) }
-
- /*** ------------------------------------------------- ------------------------------- * 小於或等於參數(shù) * ---------- --- ----------------------------------------------- --- ----------------- * * 取得$field的值小於或等於$x的文檔* * @usage = $this-> mongo_db->where_lte('foo', 20 );*/
- public function where_lte($field = "" , $x) {
- $ this->where_init($field)
- $this->wheres[$field]['$lte'] = $x;
- 回傳($this); ??> }
-
- /* ** ------------------------------------------------- ------------------------------- * 參數(shù)之間的位置* ------------ -- ------------------------------------------------ -- ---------------- * * 取得$field的值在$x和$y之間的文件* * @usage = $this->mongo_db->where_ Between ( 'foo', 20, 30);*/
- public function where_ Between($field = "", $x, $y) {
- $this->where_init($field ) ;
- $this->wheres[$ field]['$gte'] = $x;
- $this->wheres[$field]['$lte'] = $y;
- 回傳( $這個);
- }
-
- /*** ------------------------------------------------- ------------------ * ???? ?? ? ????? ?? ?? * ---------- ------------------------------------- ------- * * $field? ?? $x? $y ????? ?? ?? ??? ?????. * * @usage = $this ->mongo_db->where_between_ne('foo', 20, 30);*/
- ?? ?? where_between_ne($field = "", $x, $y) {
- $this->where_init($field);
- $this->wheres[$field]['$gt'] = $x;
- $this->wheres[$field]['$lt'] = $y;
- return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * ????? ?? ?? ?? * ------------ ------------------------------------- ------------------ * * $field? ?? $x? ?? ?? ??? ?????. * * @usage = $this->mongo_db-> where_between('foo', 20, 30);*/
- ?? ?? where_ne($field = "", $x) {
- $this->where_init($field);
- $this->wheres[$field]['$ne'] = $x;
- return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * ??? ?? * --------------- ------------------------------------- --------------- * * $field? ?? ?? ??? ?? ?? ?? ???? * * @usage = $this->mongo_db->where_or(' foo', array( 'foo', 'bar', 'blegh' );*/
- ?? ?? where_or($field = "", $values) {
- $this->where_init($field);
- $this->wheres[$field]['$or'] = $values;
- return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * ??? ??? * --------------- ------------------------------------- --------------- * * ??? ??? ?? ???? ?? ???? * * @usage = $this->mongo_db->where_and( array ( 'foo' => ; 1, 'b' => '?? ?' );*/
- ?? ?? where_and($elements_values ??= array()) {
- foreach ((array)$elements_values ??as $element => $ val) {
- $this->wheres[$element] = $val;
- } return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * MOD? ??? * --------------- ------------------------------------- --------------- * * $field % $mod = $result * * @usage = $this->mongo_db->where_mod( 'foo', 10 ?? ?? ???? , 1 );*/
- ?? ?? where_mod($field, $num, $result) {
- $this->where_init($field);
- $this->wheres[$field]['$mod'] = array($num, $result);
- return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * ???? * --------------- ------------------------------------- --------------- * * ?? ??? ??? $size int? ?? ???? * * @usage : $this->mongo_db->where_size(' foo', 1)->get('foobar');*/
- ?? ?? where_size($field = "", $size = "") {
- $this->_where_init($field );
- $this->wheres[$field]['$size'] = $size;
- ??($this);
- }
-
- /*** ------------------------------------------------- ------------------ * ????? ??? * --------------- ------------------------------------- --------------- * * $field? (???) ?? ?? ??? ??? ?????. ???? * ????? ???? ?? ??? ?????. * * @param $flags * ???? ??? ???? ?????. * i = ????? ???? ?? * m = ?? ? * x = ?? ?? ?? * l = ??? * s = dotall, "." ? ??? ???? ?? ??? ?? * u = ???? ?? * * @param $enable_start_wildcard * TRUE ??? ??? ???? ?? ? ?? "^"? ?? ? ?? * ?????. ?? ?? ? ?? ????? ?????. * ??? ?. * * @param $enable_end_wildcard * TRUE ??? ??? ???? ? ? ?? "$"? ?? ?? ?????. ?? ? ?? ?? ????? ?? ?????. * * @usage = $this->mongo_db->like('foo', 'bar', 'im', FALSE, TRUE);*/
- ?? ?? like($field = "", $value = "", $flags = "i", $enable_start_wildcard = TRUE, $enable_end_wildcard = TRUE) {
- $field = (???) Trim($field);
- $this->where_init($field);
- $value = (???) Trim($value);
- $value = quotemeta($value);
- if ($enable_start_wildcard !== TRUE) {
- $value = "^" . $?;
- } if ($enable_end_wildcard !== TRUE) {
- $value .= "$";
- } $regex = "/$value/$flags";
- $this->wheres[$field] = new MongoRegex($regex);
- return($this);
- }
-
- ?? ?? wheres($where){
- $this->wheres = $where;
- }
-
- /*** ------------------------------------------------- ------------------ * ????? ?? * -------------- ------------------------------------- ---------------- * * ??? ????? ???? ??? ?????. ?? ?????? ????? * -1, FALSE, 'desc' ?? 'DESC' ?? ???? ???. ??? ??? * 1(ASC)? ?????. * * @usage = $this->mongo_db->where_between('foo', 20, 30);*/
- ?? ?? order_by($fields = array()) {
- if (!is_array($fields) || !count($ ??)) return ;
- foreach ($fields as $col => $val) {
- if ($val == -1 || $val === FALSE || strtolower($val) == 'desc') {
- $this->sorts[$col] = -1;
- } else {
- $this->sorts[$col] = 1;
- }
- } return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * ??? ?? * --------------- ------------------------------------- --------------- * * ?? ??? ?? ? $x? ?? * * @usage = $this->mongo_db->limit($x);*/
- ?? ?? ??($x = 99999) {
- if ($x !== NULL && is_numeric($x) && $ x >= 1) {
- $this->limit = (int) $x;
- } return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * ??? ?? * --------------- ------------------------------------- --------------- * * $x?? ??? ????? ?? ??? ??????. * * @usage = $this->mongo_db->offset($x);*/
- ?? ?? ???($x = 0) {
- if ($x !== NULL && is_numeric($x) && $ x >= 1) {
- $this->offset = (int) $x;
- } return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * GET_WHERE * --- ------------------------------------- -------------- * * ??? ????? ???? ?? ???? * * @usage = $this->mongo_db->get_where('foo', array('bar' = > '??'));*/
- ?? ?? get_where($collection = "", $where = array(), $limit = 99999, $orderby=array()) {
- if (is_array($orderby) || !emptyempty($orderby)) {
- $order_by = $this->order_by($order_by);
- }
- return($this->where($where)->limit($limit)->get($collection));
- }
- ?? ?? selectA($collection = "", $limit = 99999, $orderby=array()) {
- if(intval($limit)<1){
- $limit = 999999;
- }
- $order_by = $this->order_by($orderby);
- $re = $this->limit($limit)->get($collection);
- $this->clear();
- return (??)$re;
- }
-
- ?? ?? listinfo($collection = "", $orderby=array(), $page=1, $pagesize=12) {
- $page = max(intval($page) ), 1);
- $offset = $pagesize * ($page - 1);
- $pagesizes = $offset $pagesize;
- $this->offset($offset);
- $order_by = $this->order_by($orderby);
- $re = $this->limit($pagesize)->get($collection);
- $this->limit(999999);
- $count = $this->count($collection);
- $this->pages = ???($count, $page, $pagesize);
- return (??)$re;
- }
-
- /*** ------------------------------------------------- ------------------------------- * ?? * ---------------- ------------------------------------- -------------- * * ??? ????? ???? ?? ???? * * @usage = $this->mongo_db->get('foo', array('bar' = > '??'));*/
- ?? ?? get($collection = "") {
- if (emptyempty($collection)) {
- $this- >error("MongoDB?? ??? ????? ??? ??? ???? ???.", 500);
- } $?? = ??();
- $documents = $this->db->{$collection}->find($this->wheres, $this->selects)->limit((int) $this-> ;limit)->skip((int) $this->offset)->sort($this->sorts);
- $returns = ??();
- foreach($documents? $doc?): $returns[] = $doc;
- endforeach;
- ??($returns);
- }
-
- public function getMy($collection = "") {
- if (emptyempty($collection)) {
- $this->error("???? ??? ????? MongoDB, ??? ??? ???? ???.", 500);
- } $?? = ??();
- $documents = $this->db->{$collection}->find($this->wheres, $this->selects)->limit((int) $this-> ;limit)->skip((int) $this->offset)->sort($this->sorts);
- $returns = ??();
- foreach($documents? $doc?): $returns[] = $doc;
- endforeach;
- $?? -> ???();
- ??($returns);
- }
-
- /*** ------------------------------------------------- ------------------------------- * ?? * ---------------- ------------------------------------- -------------- * * ??? ????? ???? ?? ?? * * @usage = $this->mongo_db->get('foo');*/
- ?? ?? ??($collection = "") {
- if (emptyempty($collection)) {
- $this- >error("MongoDB?? ?? ??? ????? ??? ??? ???? ???.", 500);
- } $count = $this->db->{$collection}->find($this->wheres)->limit((int) $this->limit)-> Skip((int) $this->offset)->count();
- $this->clear();
- ??($count);
- }
-
- /*** ------------------------------------------------- ------------------ * ?? * --- ------------------------------------- -------------- * * ??? ???? ? ?? ?? * * @usage = $this->mongo_db->insert('foo', $data = array() );*/
- ?? ?? insert($collection = "", $data = array(), $name='ID') {
- if (emptyempty($collection)) {
- $this->error("??? Mongo ???? ???? ?????.", 500);
- } if (count($data) == 0 || !is_array($data)) {
- $this->error("Mongo ???? ??? ??? ??? ??? ??? ??? ????.", 500 );
- } try {
- /**
- wxcity_base::load_sys_class('whtysqs','',0);
- $mongoseq_class = new whtysqs('creaseidsqs');
- $re = $mongoseq_class->query("?name=" . $collection . "&opt=put&data=1");
- **/
- $re = put_sqs('list_mongo_creaseidsqs','1');
- if(is_numeric($re)){
- $re ;
- $data[$name] = intval($re);
- }else{
- $data[$name] = intval(time());
- //die('mongosqs ??');
- }
- $this->db->{$collection}->insert($data, array('fsync' => TRUE));
- $this->clear();
- $data[$name] ??;
- } catch (MongoCursorException $e) {
- $this->error("MongoDB? ??? ?? ??: {$e->getMessage()}", 500);
- }
- }
-
- ?? ?? insertWithId($collection = "", $data = array()) {
- if (emptyempty($collection)) {
- $this- >error("??? Mongo ???? ???? ?????.", 500);
- } if (count($data) == 0 || !is_array($data)) {
- $this->error("Mongo ???? ??? ??? ??? ??? ??? ??? ????.", 500 );
- } try {
- $this->db->{$collection}->insert($data, array('fsync' => TRUE));
- $this->clear();
- 1? ?????.
- } catch (MongoCursorException $e) {
- $this->error("MongoDB? ??? ?? ??: {$e->getMessage()}", 500);
- }
- }
- /*** ------------------------------------------------- ------------------------------- * ???? * ---------------- ------------------------------------- -------------- * * ??? ????? ?? ???? * * @usage = $this->mongo_db->update('foo', $data = array()) ;*/
- ?? ?? ????($collection = "", $data = array()) {
- if (emptyempty($collection) ) {
- $this->error("????? Mongo ???? ???? ?????.", 500);
- } if (count($data) == 0 || !is_array($data)) {
- $this->error("Mongo ????? ????? ??? ??? ????? ??? ??? ????.", 500 );
- } try {
- $this->db->{$collection}->update($this->wheres, array('$set' => $data), array(' fsync' => TRUE, '??' => FALSE);
- $this->clear();
- ??(TRUE);
- } catch (MongoCursorException $e) {
- $this->error("MongoDB?? ??? ???? ??: {$e->getMessage()}", 500);
- }
- }
-
- /*** ------------------------------------------------- ------------------ * UPDATE_ALL * --- ------------------------------------- -------------- * * ??? ???? ? ?? ?? * * @usage = $this->mongo_db->update_all('foo', $data = array() );*/
- public function update_all($collection = "", $data = array()) {
- if (emptyempty( $collection)) {
- $this->error("????? Mongo ???? ???? ?????.", 500);
- } if (count($data) == 0 || !is_array($data)) {
- $this->error("Mongo ????? ????? ??? ??? ????? ??? ??? ????.", 500 );
- } try {
- $this->db->{$collection}->update($this->wheres, array('$set' => $data), array(' fsync' => TRUE, '??' =>
- ??(TRUE);
- } catch (MongoCursorException $e) {
- $this->error("MongoDB?? ??? ???? ??: {$e->getMessage()}", 500);
- }
- }
-
- /*** ------------------------------------------------- ------------------------------- * ?? * ---------------- ------------------------------------- -------------- * * ?? ??? ?? ??? ????? ?? ?? * * @usage = $this->mongo_db->delete('foo', $data = array ());*/
- ?? ?? delete($collection = "") {
- if (emptyempty($collection)) {
- $this->error("??? Mongo ???? ???? ?????.", 500);
- } try {
- $this->db->{$collection}->remove($this->wheres, array('fsync' => TRUE, 'justOne' => ??));
- $this->clear();
- ??(TRUE);
- } catch (MongoCursorException $e) {
- $this->error("MongoDB?? ??? ?? ??: {$e->getMessage()}", 500);
- }
- }
-
- /*** ------------------------------------------------- ------------------ * DELETE_ALL * --- ------------------------------------- -------------- * * ?? ??? ?? ??? ????? ?? ?? ?? * * @usage = $this->mongo_db->delete_all('foo', $data = ??());*/
- public function delete_all($collection = "") {
- if (emptyempty($collection)) {
- $this->error( "??? Mongo ???? ???? ?????.", 500);
- } try {
- $this->db->{$collection}->remove($this->wheres, array('fsync' => TRUE, 'justOne' => ??));
- ??(TRUE);
- } catch (MongoCursorException $e) {
- $this->error("MongoDB?? ??? ?? ??: {$e->getMessage()}", 500);
- }
- }
-
- /*** ------------------------------------------------- ------------------ * ADD_INDEX * --- ------------------------------------- -------------- * * ??? ????? ???? ???? ? ???? ?????. ?? ?????? ????? * -1, FALSE, 'desc' ?? 'DESC' ?? ???? ???. ??? ??? * 1(ASC)? ?????. * * @usage = $this->mongo_db->add_index($collection, array('first_name' => 'ASC', 'last_name' => -1), array('unique' => TRUE )));*/
- ?? ?? add_index($collection = "", $keys = array(), $options = array()) {
- if (emptyempty($collection)) {
- $this->error("???? ??? Mongo ???? ???? ?????.", 500);
- } if (emptyempty($keys) || !is_array($keys)) {
- $this->error("?? ???? ??? ??? MongoDB ???? ???? ??? ? ????.", 500);
- } foreach ($keys as $col => $val) {
- if ($val == -1 || $val === FALSE || strtolower($val) == 'desc') {
- $keys[$col] = -1;
- } else {
- $keys[$col] = 1;
- }
- } if ($this->db->{$collection}->ensureIndex($keys, $options) == TRUE) {
- $this->clear() ;
- return($this);
- } else {
- $this->error("MongoDB ???? ???? ????? ? ? ??? ??????.", 500);
- }
- }
-
- /*** ------------------------------------------------- ------------------ * REMOVE_INDEX * --- ------------------------------------- -------------- * * ???? ?? ?? ???? ?????. ?? ?????? ????? * -1, FALSE, 'desc' ?? 'DESC' ?? ???? ???. ??? ??? * 1(ASC)? ?????. * * @usage = $this->mongo_db->remove_index($collection, array('first_name' => 'ASC', 'last_name' => -1));*/
- ?? ?? Remove_index($collection = "", $keys = array()) {
- if (emptyempty( $collection)) {
- $this->error("???? ??? Mongo ???? ???? ?????.", 500);
- } if (emptyempty($keys) || !is_array($keys)) {
- $this->error("??? ?? ?? ??? MongoDB ????? ???? ??? ? ????.", 500);
- } if ($this->db->{$collection}->deleteIndex($keys, $options) == TRUE) {
- $this->clear();
- return($this);
- } else {
- $this->error("MongoDB ????? ???? ????? ? ? ??? ??????.", 500);
- }
- }
-
- /*** ------------------------------------------------- ------------------ * REMOVE_ALL_INDEXES * --- ------------------------------------- -------------- * * ????? ?? ???? ?????. * * @usage = $this->mongo_db->remove_all_index($collection);*/
- ?? ?? Remove_all_indexes($collection = "") {
- if (emptyempty($collection)) {
- $this->error("?? ???? ???? ?? ??? Mongo ???? ????.", 500);
- } $this->db->{$collection}->deleteIndexes();
- $this->clear();
- return($this);
- }
-
- /*** ------------------------------------------------- ------------------ * LIST_INDEXES * --- ------------------------------------- -------------- * * ???? ?? ???? ?????. * * @usage = $this->mongo_db->list_indexes($collection);*/
- public function list_indexes($collection = "") {
- if (emptyempty($collection)) {
- $this->error( "?? ???? ????? ??? Mongo ???? ????.", 500);
- } return($this->db->{$collection}->getIndexInfo());
- }
-
- /*** ------------------------------------------------- ------------------ * ?? ??? * --------------- ------------------------------------- --------------- * * ???????? ??? ???? ?????. * ?? ???? ?? ? ??? ??? ? ???? ?????!*/
- ?? ?? drop_collection($collection = "") {
- if (emptyempty($collection)) {
- $this- >error("???????? ????? ??? Mongo ???? ????.", 500);
- } $this->db->{$collection}->drop();
- TRUE? ?????.
- }
-
- /*** ------------------------------------------------- ------------------------------- * ??? * ---------------- ------------------------------------- -------------- * * ??? ??? ?? ???? ??????.*/
- ?? ??clear() {
- $this->selects = array();
- $this->wheres = ??();
- $this->limit = NULL;
- $this->offset = NULL;
- $this->sorts = ??();
- }
-
- /*** ------------------------------------------------- ------------------ * ??? ????? ?? * --------------- ------------------------------------- --------------- * * $wheres array()? ??? ????? ?????.*/
- ??? ?? where_init($param) {
- if (!isset($this->wheres[$param])) {
- $this->wheres[$param] = ??();
- }
- }
-
- ?? ?? ??($str, $t) {
- echo $str;
- ??;
- }
-
- }
-
- ?>
-
復(fù)代碼
使用范例
- $table_name=trim(strtolower($this->table_name));
- $this->mongo_db->where($where);
- $order=!emptyempty($order)?array('AID'=>'DESC'):array('AID'=>'ASC');//升序降序
- $infos=$ this->mongo_db->listinfo($table_name,$order,$page,$pagesize);
???碼
|