Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
query() method for MongoDB?
JeanAlesi
January 2016
In Mysql, you can do this:
$query = "SELECT * FROM table WHERE 1";
$result = DB::query($query)->execute()->as_array();
Is there a way I can do something like that with the MongoDB class.. Namely, I have the following Mongo query:
db.traces.find({
"device_id": 99,
"sts": {
"$gt": 0
},
"ets": {
"$lt": 10
}
});
And I want to do that... But the closest I could find, the command method, takes an array as input though.
Thanks
Harro
January 2016
Accepted Answer
Mongo_Db has a where_gt() and where_lt() method to set these boundaries. And the other is a plain where() I think. So:
$result = $mongo
->where(array('device_id' => 99))
->where_lt('ets', 10)
->where_gt('sts', 0)
->get($collection);
disclaimer: never used Mongo, so just assuming this from reading the code...
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
January 2016