alexbilbie / mongoqb
1.3
2012-11-28 09:16 UTC
Requires
- php: >=5.3.0
Requires (Dev)
This package is not auto-updated.
Last update: 2019-02-20 17:17:57 UTC
README
此项目已废弃,如想接管,请通过Twitter发消息给我 - @alexbilbie
PHP MongoDB查询构建器库
通过Packagist和Composer安装
将以下内容添加到您的composer.json文件中
{ "require": { "alexbilbie/mongoqb": "*" } }
然后运行
composer install
通过Git安装
git clone git://git@github.com:alexbilbie/MongoQB
下载zip/tarball文件
下载最新版本
(注意zip/tarball不包括任何单元测试或composer文件)
单元测试
该库目前有100%的单元测试覆盖率。要运行单元测试套件,请确保您已安装MongoDB并在本地运行,无需身份验证且使用默认端口 - 27017。
然后运行
composer update --dev
cd vendor/alexbilbie/mongoqb
phpunit -c tests/phpunit.xml
示例用法
连接到数据库
$qb = \MongoQB\Builder(array( 'dsn' => 'mongodb://user:pass@localhost:27017/databaseName' );
插入文档
$qb->insert('collectionName', [ 'name' => 'Alex', 'age' => 22, 'likes' => ['whisky', 'gin'] ]);
更新单个文档
$qb ->where(['name' => 'Alex']) ->set([ 'country' => 'UK', 'job' => 'Developer' ]) ->push('likes', ['PHP', 'coffee']) ->update('collectionName');
删除单个文档
$qb ->where(['name' => 'Alex']) ->delete('collectionName');
搜索匹配的文档
$results = $qb ->whereGt('age', 21) ->whereIn('likes', ['whisky']) ->where('country', 'UK') ->get('collectionName');
如果发现任何错误,请在问题跟踪器中提交报告
如果您认为这个软件很有用,请考虑捐赠,谢谢 =]