Skip to content

Commit

Permalink
Issue #2194027 by KelvinWong, sphism: Fix up database topic docs exam…
Browse files Browse the repository at this point in the history
…ple queries
  • Loading branch information
jhodgdon-drp committed Mar 4, 2014
1 parent 627a891 commit 67401f3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions includes/database/database.inc
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
* For example, one might wish to return a list of the most recent 10 nodes
* authored by a given user. Instead of directly issuing the SQL query
* @code
* SELECT n.nid, n.title, n.created FROM node n WHERE n.uid = $uid LIMIT 0, 10;
* SELECT n.nid, n.title, n.created FROM node n WHERE n.uid = $uid
* ORDER BY n.created DESC LIMIT 0, 10;
* @endcode
* one would instead call the Drupal functions:
* @code
* $result = db_query_range('SELECT n.nid, n.title, n.created
* FROM {node} n WHERE n.uid = :uid', 0, 10, array(':uid' => $uid));
* FROM {node} n WHERE n.uid = :uid
* ORDER BY n.created DESC', 0, 10, array(':uid' => $uid));
* foreach ($result as $record) {
* // Perform operations on $record->title, etc. here.
* }
Expand Down

0 comments on commit 67401f3

Please sign in to comment.