Home ›
Drupal database layer (up to the D6 era) and limit clauses: use db_query_range()Drupal database layer (up to the D6 era) and limit clauses: use db_query_range()
Submitted by Benjamin Melançon on April 1, 2009 - 1:41pm
Variables passed in first, and then a start and as stop value for indexing (zero and ten, here).
<?php
$result = db_query_range(db_rewrite_sql($sql), $type, $status, 0, 10);
?>
An example from node module's search integration, node_update_index(), makes it clearer:
<?php
$limit = (int)variable_get('search_cron_limit', 100);
// ...
$result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);
?>
Resolution
Searched words:
drupal mysql db_query limit
Comments
Post new comment