Skip to content

Commit 55cdd8d

Browse files
committed
update README
1 parent 3e25076 commit 55cdd8d

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
This is a small easy-to-use PHP component for working with a database by PDO. It provides some public methods to compose SQL queries and manipulate data. Each SQL query is prepared and safe. PDO (see `Connection` class) fetches data to _arrays_ by default. At present time the component supports MySQL and SQLite (file or memory).
1010

11-
**PAY ATTENTION! v0.2 and v0.3+ are incompatible.**
11+
**PAY ATTENTION! v0.2 and v0.3+ are incompatible.**
1212

1313
## Contributing
1414

@@ -48,7 +48,7 @@ to the `require section` of your `composer.json` file.
4848
- `column()` executes SQL query and return the first column of result (`fetchColumn()`)
4949
- `pluck($key_index, $col_index)` executes SQL query and returns an array (the key (usually ID) and the needed column of result), `key_index` is `0` and `col_index` is `1` by default
5050
- `go()` this method is for non `SELECT` queries. it executes SQL query and return nothing (but returns the last inserted row ID for `INSERT` method)
51-
- `count()` prepares a query with SQL `COUNT()` function
51+
- `count()` prepares a query with SQL `COUNT(*)` function and executes it
5252
- `exists()` returns `true` if SQL query result has a row
5353
- `query($sql, $params[], $fetch_type)` executes prepared `$sql` with `$params`. it can be used for custom queries
5454
- 'SQL' methods are presented in [Usage section](#usage-examples)
@@ -119,6 +119,25 @@ $results = $query->select('users')->where([['name', 'NOT LIKE', '%John%']])->all
119119
```sql
120120
SELECT * FROM `users` WHERE (`name` NOT LIKE '%John%');
121121
```
122+
- Select a row with a `IS NULL` and `IS NOT NULL` condition (since 0.3.5)
123+
```php
124+
$results = $query->select('users')->isNull('phone')->all();
125+
# or
126+
$results = $query->select('users')->where([['phone', 'is null']])->all();
127+
```
128+
```sql
129+
SELECT * FROM `users` WHERE (`phone` IS NULL);
130+
```
131+
```php
132+
$results = $query->select('customers')->isNotNull('address')->all();
133+
# or
134+
$results = $query->select('customers')->notNull('address')->all();
135+
# or
136+
$results = $query->select('customers')->where([['address', 'is not null']])->all();
137+
```
138+
```sql
139+
SELECT * FROM `customers` WHERE (`address` IS NOT NULL);
140+
```
122141
- Select rows with `OFFSET` and `LIMIT`
123142
```php
124143
$results = $query->select('posts')
@@ -352,13 +371,17 @@ $query->delete('comments')
352371
DELETE FROM `comments` WHERE `user_id` = 10;
353372
```
354373
- Truncate a table
374+
375+
This method will be moved to another class
355376
```php
356377
$query->truncate('users')->go();
357378
```
358379
```sql
359380
TRUNCATE TABLE `users`;
360381
```
361382
- Drop a table
383+
384+
This method will be moved to another class
362385
```php
363386
$query->drop('temporary')->go();
364387
```

0 commit comments

Comments
 (0)