Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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)
Comment | File | Size | Author |
---|---|---|---|
#2 | sample-code-uses-incorrect-variable-1683836-2.patch | 599 bytes | mjonesdinero |
Comments
Comment #1
jhodgdonGood catch! Should be a quick fix...
Comment #2
mjonesdinero CreditAttribution: mjonesdinero commentedattach is the patch change the comment from is on the loop..
Comment #3
lyricnz CreditAttribution: lyricnz commentedLooks good
Comment #4
jhodgdonThanks! Committed to 8.x. Patch needs porting to 7.x (different file).
Comment #5
jhodgdonNever mind, I got it to apply to 7.x by switching to the right sub-directory. Thanks again!