API page: http://api.drupal.org/api/drupal/includes%21database%21database.inc/grou...

The sample code on the Database abstraction layer page includes the following code:

$result = db_query_range('SELECT n.nid, n.title, n.created
  FROM {node} n WHERE n.uid = :uid', 0, 10, array(':uid' => $uid));
foreach ($result as $record) {
  // Perform operations on $node->title, etc. here.

The comment should refer to $record not $node (or the loop should use $node)

#2 sample-code-uses-incorrect-variable-1683836-2.patch599 bytesmjonesdinero
PASSED: [[SimpleTest]]: [MySQL] 37,296 pass(es).
[ View ]


jhodgdon’s picture

Version:7.x-dev» 8.x-dev
Issue tags:+Novice, +needs backport to D7

Good catch! Should be a quick fix...

mjonesdinero’s picture

Assigned:Unassigned» mjonesdinero
Status:Active» Needs review
new599 bytes
PASSED: [[SimpleTest]]: [MySQL] 37,296 pass(es).
[ View ]

attach is the patch change the comment from is on the loop..

lyricnz’s picture

Status:Needs review» Reviewed & tested by the community

Looks good

jhodgdon’s picture

Version:8.x-dev» 7.x-dev
Status:Reviewed & tested by the community» Patch (to be ported)

Thanks! Committed to 8.x. Patch needs porting to 7.x (different file).

jhodgdon’s picture

Status:Patch (to be ported)» Fixed

Never mind, I got it to apply to 7.x by switching to the right sub-directory. Thanks again!

Automatically closed -- issue fixed for 2 weeks with no activity.