@@ -14,6 +14,7 @@ MysqliDb -- Simple MySQLi wrapper with prepared statements
1414** [ Properties Sharing] ( #properties-sharing ) **
1515** [ Joining Tables] ( #join-method ) **
1616** [ Subqueries] ( #subqueries ) **
17+ ** [ EXISTS / NOT EXISTS condition] ( #exists--not-exists-condition ) **
1718** [ Helper Functions] ( #helper-commands ) **
1819** [ Transaction Helpers] ( #transaction-helpers ) **
1920
@@ -275,16 +276,19 @@ print_r ($products);
275276
276277### Properties sharing
277278Its is also possible to copy properties
279+
280+ Simple pagination example:
278281``` php
279282$db->where ("agentId", 10);
283+ $db->where ("active", true);
280284
281285$customers = $db->copy ();
282- $res = $customers->get ("customers");
283- // SELECT * FROM customers where agentId = 10
286+ $res = $customers->get ("customers", Array (10, 10) );
287+ // SELECT * FROM customers where agentId = 10 and active = 1 limit 10, 10
284288
285- $db->orWhere ("agentId ", 20 );
286- $res = $db->get ("users") ;
287- // SELECT * FROM users where agentId = 10 or agentId = 20
289+ $res = $ db->getOne ("customers ", "count(id) as cnt" );
290+ echo "total records found: " . $res['cnt'] ;
291+ // SELECT count(id) FROM users where agentId = 10 and active = 1
288292```
289293
290294### Subqueries
@@ -313,6 +317,17 @@ $data = Array (
313317$id = $db->insert ("products", $data);
314318// Gives INSERT INTO PRODUCTS (productName, userId, lastUpdated) values ("test product", (SELECT name FROM users WHERE id = 6), NOW());
315319```
320+
321+ ###EXISTS / NOT EXISTS condition
322+ ``` php
323+ $sub = $db->subQuery();
324+ $sub->where("company", 'testCompany');
325+ $sub->get ("users", null, 'userId');
326+ $db->where (null, $sub, 'exists');
327+ $products = $db->get ("products");
328+ // Gives SELECT * FROM products WHERE EXISTS (select userId from users where company='testCompany')
329+ ```
330+
316331### Helper commands
317332Reconnect in case mysql connection died
318333``` php
0 commit comments