Skip to content

Commit

Permalink
doc(README.md) add missing doc entries
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatume committed Feb 23, 2024
1 parent 1546ba4 commit 9ea0ffd
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ composer require stellarwp/db
- [Inherited from `$wpdb`](#inherited-from-wpdb)
- [`get_var()`](#get_var)
- [`get_col()`](#get_col)
- [`generate_col()`](#get_col)
- [`get_results()`](#get_results)
- [`generate_results()`](#generate_results)
- [`esc_like()`](#esc_like)
- [`remove_placeholder_escape()`](#remove_placeholder_escape)

Expand Down Expand Up @@ -930,6 +933,55 @@ $meta_values = DB::get_col(
);
```

### `generate_col()`

Returns a Generator that will produce an array of values for the column for the given query.
Differrently from the `get_col()` method, this method will run unbounded queries (queries without a `LIMIT` set) in batches, ensuring as-efficient-as-possible use of the database and memory.

```php
$meta_values = DB::generate_col(
DB::table( 'postmeta' )
->select( 'meta_value' )
->where( 'meta_key', 'some_key' )
->getSQL()
);

foreach( $meta_values as $meta_value ) {
// Do something with the meta value.
}
```

### `get_results()`

Returns an array of rows for for the given query.

```php
$private_posts = DB::get_results(
DB::table( 'posts' )
->select( '*' )
->where( 'post_status', 'private' )
->getSQL()
);
```

### `generate_results()`

Returns a Generator that will produce an array of rows for the given query.
Differrently from the `get_results()` method, this method will run unbounded queries (queries without a `LIMIT` set) in batches, ensuring as-efficient-as-possible use of the database and memory.

```php
$private_posts = DB::generate_results(
DB::table( 'posts' )
->select( '*' )
->where( 'post_status', 'private' )
->getSQL()
);

foreach( $private_posts as $private_post ) {
// Do something with the post.
}
```

### `esc_like()`

Escapes a string with a percent sign in it so it can be safely used with [Where LIKE](#where-like-clauses) without the percent sign being interpreted as a wildcard character.
Expand Down

0 comments on commit 9ea0ffd

Please sign in to comment.