https://github.com/masylum/php_mongo
Tiny wrapper of the php mongo client
https://github.com/masylum/php_mongo
Last synced: 6 months ago
JSON representation
Tiny wrapper of the php mongo client
- Host: GitHub
- URL: https://github.com/masylum/php_mongo
- Owner: masylum
- Created: 2010-12-21T15:41:09.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2010-12-21T15:54:43.000Z (over 15 years ago)
- Last Synced: 2025-01-22T12:32:40.501Z (over 1 year ago)
- Homepage:
- Size: 93.8 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# php_mongo
php_mongo is a tiny wrapper for the php mongo client.
Its based (I would say, a shameless copy) on [simplemongophp](http://github.com/ibwhite/simplemongophp)
## how does it work?
PHPMongo is not a ORM. Is just a bunch of static functions that only share the connection.
PHPMongo::connect(array(
user: 'xxxxx'
password: 'xxxxxx'
uri: foo.domain.com
port: 27031
db: 'db_name'
));
## examples
PHPMongo::find('cats')->sort(array('order' => 1, 'name' => 1));
PHPMongo::group(
'cats',
array('dogs' => 1, 'order' => 1),
array('count' => 0),
"function (obj, prev) { prev.count++; }",
$conditions
);
PHPMongo::mapReduce(
'cat',
'function(){emit("max", this.order);}',
'function(key, values){return Math.max.apply(Math, values);}'
)->getNext();
PHPMongo::distinct('dogs', 'foo.bar', array(
'foo' => false,
'bar' => false
));
PHPMongo::findOne('ads', array('location.country.woeid' => (int)$woeid, 'confirmed' => true, 'banned' => false, 'deleted' => false));
PHPMongo::insert('contacts', array('foo' => 'bar'));
// etc...