Mangodb的安装与配置
Posted yujianni
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mangodb的安装与配置相关的知识,希望对你有一定的参考价值。
操作
|
格式
|
范例
|
RDBMS中的类似语句
|
等于
|
{<key>:<value>}
|
db.col.find({"by":"菜鸟教程"}).pretty()
|
where by = ‘菜鸟教程‘
|
小于
|
{<key>:{$lt:<value>}}
|
db.col.find({"likes":{$lt:50}}).pretty()
|
where likes < 50
|
小于或等于
|
{<key>:{$lte:<value>}}
|
db.col.find({"likes":{$lte:50}}).pretty()
|
where likes <= 50
|
大于
|
{<key>:{$gt:<value>}}
|
db.col.find({"likes":{$gt:50}}).pretty()
|
where likes > 50
|
大于或等于
|
{<key>:{$gte:<value>}}
|
db.col.find({"likes":{$gte:50}}).pretty()
|
where likes >= 50
|
不等于
|
{<key>:{$ne:<value>}}
|
db.col.find({"likes":{$ne:50}}).pretty()
|
where likes != 50
|
<?php
$manager = new MongoDBDriverManager("mongodb://127.0.0.1:27017");
//print_r($manager);
//查询
/*
//查询条件
$filter = ["name"=>‘shuaige‘];
$query = new MongoDBDriverQuery($filter);
$cursor = $manager->executeQuery(‘yyy.user‘, $query);
foreach ($cursor as $document) {
print_r($document);
}
*/
//插入数据
/*
$bulk = new MongoDBDriverBulkWrite;
$bulk->insert([‘name‘=>‘zzz‘,‘age‘=>18]);
$bulk->insert([‘name‘=>‘zsy‘,‘age‘=>17]);
$res = $manager->executeBulkWrite(‘yyy.user‘, $bulk);
print_r($res);
*/
//更新
/*
$bulk = new MongoDBDriverBulkWrite;
$bulk->update([‘name‘=>‘zzz‘],[‘$set‘=>[‘girl‘=>‘LYF‘]]);
$writeConcern = new MongoDBDriverWriteConcern(MongoDBDriverWriteConcern::MAJORITY, 1000);
$result = $manager->executeBulkWrite(‘yyy.user‘, $bulk, $writeConcern);
print_r($result);
*/
//删除
$bulk = new MongoDBDriverBulkWrite;
$bulk->delete([‘name‘=>‘shuaige‘]);
$writeConcern = new MongoDBDriverWriteConcern(MongoDBDriverWriteConcern::MAJORITY, 1000);
$result = $manager->executeBulkWrite(‘yyy.user‘, $bulk, $writeConcern);
print_r($result);
Mangodb的服务启动:
./bin/mongod --dbpath=/usr/local/mongodb/data/ --logpath=/usr/local/mongodb/logs/log --bind_ip=0.0.0.0 --fork
以上是关于Mangodb的安装与配置的主要内容,如果未能解决你的问题,请参考以下文章