PHP????MongoDB ??????????
???????????? ???????[ 2014/5/28 11:39:23 ] ????????PHP MongoDB ?????
???????и???????????php????mongoDb??????????????mongoDb??????????£??????????......
????1.????MongoDB?????
$conn = new Mongo();
??????????
//$conn=new Mongo(); #??????????????????.
//$conn=new Mongo(“172.21.15.69″); #???????????
//$conn=new Mongo(“xiaocai.loc:10086″); #?????????????????
//$conn=new Mongo(“xiaocai.loc”??array(“replicaSet”=>true)); #???????
//$conn=new Mongo(“xiaocai.loc”??array(“persist”=>”t”)); #???????
//$conn=new Mongo(“mongodb://sa:123@localhost”); #???????????
//$conn=new Mongo(“mongodb://localhost:27017??localhost:27018″); #????????????
//$conn=new Mongo(“mongodb:///tmp/mongo-27017.sock”); #???????
//$conn=new Mongo(“mongodb://admin_miss:miss@localhost:27017/test”??array(‘persist’=>’p'??”replicaSet”=>true)); #????
|
????2.???????????
????$db=$conn->mydb; #???mydb?????
????$collection=$db->myTable; #?????(???’??’)
????//$collection=$db->selectCollection(myTable); #?????д??
????//$collection=$conn->mydb->myTable; #??????д??
????3.??????????
$array=array(‘column_name’=>’col’.rand(100??999)??’column_exp’=>’xiaocai’);
$result=$collection->insert($array); #??????
echo “????ID:”.$array['_id']; #MongoDB?????????????
var_dump($result); #????:bool(true)
//**?????а????????????????????(????). **/
$array=array(‘column_name’=>’col’.rand(100??999)??’column_exp’=>’xiaocai2′);
$result=$collection->insert($array??true); #??????MongoDB???????????????????.(???д??????????????ò???????????)
echo “????ID:”.$array['_id']; #MongoDB?????????????
var_dump($result); #????:array(3) { ["err"]=> NULL ["n"]=> int(0) ["ok"]=> float(1) }
|
????4.??????????
//** ?????? ??????? **/
$where=array(‘column_name’=>’col123′);
$newdata=array(‘column_exp’=>’GGGGGGG’??'column_fid’=>444);
$result=$collection->update($where??array(‘$set’=>$newdata)); #$set:???????????????????????$pull $pullAll $pop $inc???????????????÷?
/*
* ???:
* ?????
* {“_id”:ObjectId(“4d635ba2d549a02801000003″)??”column_name”:”col123″??”column_exp”:”xiaocai”}
* ???滻????
* {“_id”:ObjectId(“4d635ba2d549a02801000003″)??”column_name”:”col123″??”column_exp”:”GGGGGGG”??”column_fid”:444}
*/
//** ?滻???? ??????????**/
$where=array(‘column_name’=>’col709′);
$newdata=array(‘column_exp’=>’HHHHHHHHH’??'column_fid’=>123);
$result=$collection->update($where??$newdata);
/*
* ???:
* ?????
* {“_id”:ObjectId(“4d635ba2d549a02801000003″)??”column_name”:”col709″??”column_exp”:”xiaocai”}
* ???滻????
* {“_id”:ObjectId(“4d635ba2d549a02801000003″)??”column_exp”:”HHHHHHHHH”??”column_fid”:123}
*/
//** ???????? **/
$where=array(‘column_name’=>’col’);
$newdata=array(‘column_exp’=>’multiple’??’91u’=>684435);
$result=$collection->update($where??array(‘$set’=>$newdata)??array(‘multiple’=>true));
/**
* ????’column_name’='col’???????
*/
//** ?????? **/
$where=array(’91u’=>684435);
$newdata=array(‘column_exp’=>’edit’);
$result=$collection->update($where??array(‘$set’=>$newdata??’$inc’=>array(’91u’=>-5)));
/**
* ????91u=684435???????????91u???5
*/
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
?????????????????????????Щ????????????????????TC???????????????Щ???????????????????????????????????????????????(java .net ?????)???mysql???????????????????ж????д???Python???????????????(DB2)??????BufferPool????????????????????????????????6??????????????????滮???????????????-????????SQL Server???????????????????λ?????PHP??SQL????????????????????Pythonд???NoSQL????????? SQL ?е????????????? SQL ?е?????????Java???????:?????MySQL???????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????