There is no license information available for the latest version (v0.2.1) of this package.

MongoDB PHP Query Builder

v0.2.1 2018-11-14 08:30 UTC

This package is auto-updated.

Last update: 2020-05-27 09:35:36 UTC


MongoDB Query Builder (PHP)


composer require akalod/mongoq


  • Case Insensetive "All where condition" (exist ObjectId)
  • Auto Integer implement
  • Auto match DocumentId for update method
  • Values of unsent keys can be kept for update methods

using examples with alias

Use akalod/mongoq as DB;

// static using example

// construct example of multi line connections
$x = DB::init("mongodb://localhost","a_db");
$r = DB::init("mongodb://username:password@remote.server.com","b_db");

// or 
// you can use multiple where condition 
... ->where('status',1)->where('owner_id',2) 
.. ->where(['status'=>1,'owner_id'=>2])

// deleting examples
  ->deleteAll(); // or delete() for removing one result.

// getting first data
.. ->first();
// or you can use limit
.. ->limit(1)->get();

// inserting Data

// if update else create (:
$r->collection('tasks')->updateOrCreate(Array()) // you can use this method with where condition

// data updating...
--result like this before using
    "_id" : ObjectId("5bea74ccdfce107bd4d781fb"),
    "address" : "blaaa blaaaaa",
    "email" : "syhnyldz@*.com"
-- after using.
    "_id" : ObjectId("5bea74ccdfce107bd4d781fb"),
    "address" : "blaaa blaaaaa",
    "email" : "seyhan@d*.com",
-- if you use the force your result shoud like this
    "_id" : ObjectId("5bea74ccdfce107bd4d781fb"), 
    "email" : "seyhan@d*.com",

// you can list null and non exist keys
.. ->whereIsNull('name')->get(); //or whatever you want (delete/update)
// or you can list non Null and exist keys
.. ->whereNotNull('name')->get(); //whatever
// whereLike method is similar that  "where like '%key%'" on SQL
.. ->whereLike('key','val')->get(); //bla bla

//create collection (table)

//drop collection


//order by ..
    ->orderBy('name') //default DESC
// or