Method | Description | |
---|---|---|
__construct ( array $args = [] ) | Creates an iterator over a database table. |
Method | Description | |
---|---|---|
build_fields ( $fields ) | ||
build_where_conditions ( $where ) |
foreach( new Iterators\Table( array( 'table' => $wpdb->posts, 'fields' => array( 'ID', 'post_content' ) ) ) as $post ) {
count_words_for( $post->ID, $post->post_content );
}
foreach( new Iterators\Table( array( 'table' => $wpdb->posts, 'where' => 'ID = 8 OR post_status = "publish"' ) ) as $post ) {
…
}
foreach( new PostIterator( array( 'table' => $wpdb->posts, 'where' => array( 'post_status' => 'publish', 'post_date_gmt BETWEEN x AND y' ) ) ) as $post ) {
…
}
public __construct ( array $args = [] ) | ||
$args | array | Supported arguments: table – the name of the database table fields – an array of columns to get from the table, '*' is a valid value and the default where – conditions for filtering rows. Supports two formats: = string – this will be the where clause = array – each element is treated as a condition if it's positional, or as column => value if it's a key/value pair. In the latter case the value is automatically quoted and escaped append - add arbitrary extra SQL |