Issue #2194027 by KelvinWong, sphism, danblack: Fix example query in database topic docs

8.0.x
Jennifer Hodgdon 2014-02-27 14:37:56 -08:00
parent a2ee636f34
commit 74bb4e2c07
1 changed files with 4 additions and 2 deletions

View File

@ -39,12 +39,14 @@ use Drupal\Core\Database\Query\Condition;
* For example, one might wish to return a list of the most recent 10 rows * For example, one might wish to return a list of the most recent 10 rows
* authored by a given user. Instead of directly issuing the SQL query * authored by a given user. Instead of directly issuing the SQL query
* @code * @code
* SELECT e.id, e.title, e.created FROM example e WHERE e.uid = $uid LIMIT 0, 10; * SELECT e.id, e.title, e.created FROM example e WHERE e.uid = $uid
* ORDER BY e.created DESC LIMIT 0, 10;
* @endcode * @endcode
* one would instead call the Drupal functions: * one would instead call the Drupal functions:
* @code * @code
* $result = db_query_range('SELECT e.id, e.title, e.created * $result = db_query_range('SELECT e.id, e.title, e.created
* FROM {example} e WHERE e.uid = :uid', 0, 10, array(':uid' => $uid)); * FROM {example} e WHERE e.uid = :uid
* ORDER BY e.created DESC', 0, 10, array(':uid' => $uid));
* foreach ($result as $record) { * foreach ($result as $record) {
* // Perform operations on $record->title, etc. here. * // Perform operations on $record->title, etc. here.
* } * }