Home / Keyword Tools / NinjaDB — WordPress Plugins

NinjaDB — WordPress Plugins


A light-weight, expressive question builder for WordPress. NInjaDB use the identical $wbdp occasion and strategies, It will make it easier to to jot down $wpdb queries simply and expressively. At least PHP 5.three is required.

It has some superior options like:
– Query Like Laravel Basic Queries
– Where, orWhere strategies
– Search information in all of the columns or particular columns
– Easily Implement Pagination
– use insert, replace or delete strategies expressively.

The syntax is kind of much like Laravel’s question builder.

Simple Query:

The question under returns the row the place id = three, null if no rows.

$row = ninjaDB(‘my_table’)->discover(three);

Full Queries:

$question = ninjaDB(‘my_table’)->the place(‘post_author’, ‘=’, 1); // for equal you possibly can simply use the place(‘post_author, 1);
// Get consequence as array of objects

Full Usage API

### Initiate

// Select a desk
$question = ninjaDB()->desk(‘publish’); // publish is the desk title with out prefix;

OR You can cross your desk title as an argument

// Select a desk
$question = ninjaDB(‘my_table’); // publish is the desk title with out prefix;<h3>Query</h3>

Get Easily

The question under returns the (first) row the place id = three, null if no rows.

$row = ninjaDB(‘my_table’)->discover(three);

Access your row like, echo $row->title. If your subject title just isn’t id then cross the sector title as second parameter ninjaDB(‘my_table’)->discover(three, ‘author_id’);.

The question under returns the all rows as array of objects the place author_id = three, null if no rows.

$consequence = ninjaDB(‘my_table’)->discoverAll(‘author_id’, three);

$question = ninjaDB(‘my_table’)->choose(‘*’);

Multiple Selects
->choose(array(‘myfield1’, ‘myfield2’, ‘amyfield3’));

Using choose technique a number of occasions choose(‘a’)->choose(‘b’) can even choose a and b. Can be helpful if you wish to do conditional selects (inside a PHP if).

Get All

Return an array of objects.

$question = ninjaDB(‘my_table’)->the place(‘author_id’, 1);
$consequence = $query->get();

You can loop by way of it like:

foreach ($consequence as $row)

Get First Row
$question = ninjaDB(‘my_table’)->the place(‘author_id’, 1);
$row = $query->first();

Returns the primary row, or null if there isn’t any document. Using this technique you can even be certain that if a document exists. Access these like echo $row->title.

Get Rows Count, MAX, MIN, AVerage, SUM
$question = ninjaDB(‘my_table’)->the place(‘author_id’, 1);
$rely = $query->rely();
$max = $query->max(‘views’); // Where `views` is the column title and all these will return integer / float
$min = $query->min(‘views’);
$avg = $query->avg(‘views’);
$avg = $query->avg(‘views’);
$sum = $query->sum(‘views’);


Basic syntax is (fieldname, operator, worth), should you give two parameters then = operator is assumed. So the place(‘title’, ‘jewel’) and the place(‘title’, ‘=’, ‘jewel’) is similar.

->the place(‘title’, ‘=’, ‘jewel’)
->whereNot(‘age’, ‘>’, 25)
->orWhere(‘description’, ‘LIKE’, ‘%question%’);

the placeIn
->the placeIn( ‘id’, array(1,2,three) )

Limit and Offset

// or you should utilize aliases

Order By
->orderBy(‘id’, ‘ASC’);

$information = array(
‘title’ => ‘Jewel’,
‘description’ => ‘Hello, There’
$insertId = ninjaDB(‘my_table’)->insert($information);

insert() technique returns the insert id. optionally you possibly can cross $format of your information as `->insert($information, $format);` the place `$format` is an array of codecs to be mapped to every of the worth in $information

Batch Insert
$information = array(
‘title’ => ‘Jewel’,
‘description’ => ‘Hello, There’
‘title’ => ‘Adre’,
‘description’ => ‘Hello, I’m Adre Astrian’
$insertIds = ninjaDB(‘my_table’)->batch_insert($information);

In case of batch insert, it can return an array of insert ids.

$information = array(
‘title’ => ‘Shahjahan Jewel’,
‘description’ => ‘Hello, There’

ninjaDB(‘my_table’)->the place(‘id’, 5)->replace($information);

Will replace the title subject to Shahjahan Jewel and outline subject to Hello, There the place id = 5.

ninjaDB(‘my_table’)->the place(‘id’, ‘>’, 5)->delete();

Will delete all of the rows the place id is larger than 5.

If you discover any typo or prolong any performance then please edit and ship a pull request.


[ ] be a part of()
[ ] whereIN()
[ ] whereNotIN()
[ ] whereBetween
[ ] whereNotBetween
[ ] Having
[ ] GroupBy
[ ] selectDistinct

If you want to implement any of the TODO please be at liberty to do and do a pull request

And, lastly, take into account to contribute to this plugin right here.


About admin

Check Also

Fortnite map for Dummies

Fortnite map for Dummies

and another thing a lot more fortnite’s trailer is usually a trash That is why …