WP_CLI\Iterators
Query::__construct()
Creates a new query iterator
This will loop over all users, but will retrieve them 100 by 100:
foreach( new Iterators\Query( 'SELECT * FROM users', 100 ) as $user ) { tickle( $user ); }
Метод класса: Query{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$Query = new Query(); $Query->__construct( $query, $chunk_size );
- $query(строка) (обязательный)
- The query as a string. It shouldn't include any LIMIT clauses
- $chunk_size(int)
- How many rows to retrieve at once; default value is 500 (optional)
По умолчанию: 500
Код Query::__construct() Query:: construct WP-CLI 2.8.0-alpha
public function __construct( $query, $chunk_size = 500 ) { $this->query = $query; $this->count_query = preg_replace( '/^.*? FROM /', 'SELECT COUNT(*) FROM ', $query, 1, $replacements ); if ( 1 !== $replacements ) { $this->count_query = ''; } $this->chunk_size = $chunk_size; $this->db = $GLOBALS['wpdb']; }