Skip to content

Commit 8307447

Browse files
committed
Added EXISTS api to readme
1 parent c35d221 commit 8307447

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -316,6 +317,17 @@ $data = Array (
316317
$id = $db->insert ("products", $data);
317318
// Gives INSERT INTO PRODUCTS (productName, userId, lastUpdated) values ("test product", (SELECT name FROM users WHERE id = 6), NOW());
318319
```
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+
319331
### Helper commands
320332
Reconnect in case mysql connection died
321333
```php

0 commit comments

Comments
 (0)