php实现的mongodb操作类实例_

php实现的mongodb操作类实例_

ID:63497896

大小:20.03 KB

页数:43页

时间:2021-08-24

php实现的mongodb操作类实例__第1页
php实现的mongodb操作类实例__第2页
php实现的mongodb操作类实例__第3页
php实现的mongodb操作类实例__第4页
php实现的mongodb操作类实例__第5页
资源描述:

《php实现的mongodb操作类实例_》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、php实现的mongodb操作类实例_本文实例讲解并描述了php实现的mongodb操作类。分享给大家供大家参考。具体如下:?php/**Tochangethistemplate,chooseTools

2、Templates*andopenthetemplateintheeditor.*/classmongo_db{private$config;private$connection;private$db;private$connection_string;private$host;private$port;private$user;priva

3、te$pass;private$dbname;private$persist;private$persist_key;private$selects=array();private$wheres=array();private$sorts=array();private$limit=999999;private$offset=0;private$timeout=200;private$key=0;/****CONSTRUCTOR***AutomaticallycheckiftheMongoPECLextensionhasbeeninstal

4、led/enabled.*GeneratetheconnectionstringandestablishaconnectiontotheMongoDB.*/publicfunction__construct(){if((IS_NOSQL!=1)){return;}if(!class_exists('Mongo')){//$this-error("TheMongoDBPECLextensionhasnotbeeninstalledorenabled",500);}$configs=wxcity_base::load_config("cache

5、","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-

6、key+$i;$key=$n=$num?$n-$num:$n;$this-config=$configs['connect'][$key];$status=$this-connect();if($status!=false){$keys['mongo_db']=$key;$this-key=$key;$data="?phpreturn".var_export($keys,true).";?";file_put_contents(WHTY_PATH.'configs/double.php',$data,LOCK_EX);break;}

7、}}if($status==false){die('mongoDBnotconnect');}}function__destruct(){if((IS_NOSQL!=1)){return;}if($this-connection){$this-connection-close();}}/****CONNECTTOMONGODB***EstablishaconnectiontoMongoDBusingtheconnectionstringgeneratedin*theconnection_string()method.If'mongo_per

8、sist_key'wassettotrueinthe*configfile,establishapersistentconnection.Weallowforonlythe'persist'*optiontobesetbecausewewanttoestablishaconnectionimmediately.*/privatefunctionconnect(){$this-connection_string();$options=array('connect'=true,'timeout'=$this-timeout);try{$this

9、-connection=newMongo($this-connection_string,$options);$this-db=$this-connection-{$this-d

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。