centos7下php使用mongodb
yum -y install mongodb mongodb-devel mongodb-server php-pecl-mongo
测试:
<?php$m = new MongoClient();$db = $m->mydb;$collection = $db->mycol;$document = array( "title" => "测试标题", "description" => "mongodb", "likes" => 100, "url" => "imlee.top");$collection->insert($document);$cursor = $collection->find();foreach($cursor as $dom){ var_dump($dom);}
输出:
array(5) {["_id"]=>object(MongoId)#8 (1) {["$id"]=>string(24) "5ac0d90bbb8b88b2438b4567"}["title"]=>string(12) "测试标题"["description"]=>string(7) "mongodb"["likes"]=>int(100)["url"]=>string(9) "imlee.top"}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。