内容目录
- <?php
- define(‘MONGO_CONF’,‘mongodb://localhost:27017’);
- $client = new MongoClient(MONGO_CONF);
- // 选择一个数据库和要操作的集(如果没有数据库默认创建)
- $collection = $client ->selectDB(‘rrs_result’)->selectCollection(‘content’);
- /*
- // 添加
- $content = array(
- ‘title’=>’海浪-陈捷’,
- ‘author’=>’陈捷’,
- ‘url’=>’http://www.chenjie.info’,
- );
- $collection->insert($content);
- */
- /*
- // 查询
- $colle = $collection->find(array(‘title’=>’海浪-陈捷’));
- foreach ($colle as $key => $val)
- {
- var_dump($val);
- }
- */
- /*
- // 修改
- $where = array(‘title’=>’海浪-陈捷’);
- $set = array(‘title’=>’海浪’);
- $collection->update($where,array(
- ‘$set’=>$set,
- ));
- */
- /*
- //删除
- $collection->remove(array(
- ‘title’=>’海浪’,
- ));
- */
- ?>