Created
February 1, 2012 21:15
-
-
Save dergachev/1719517 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Notice the place holders are now done using the same syntax as PDOs (:uid) | |
// Placeholders also don't need to be quoted anymore. | |
$uid = 1; | |
$result = db_query('SELECT n.nid, n.title, n.created FROM {node} n | |
WHERE n.uid = :uid', array(':uid' => $uid)); | |
// $result is an iterable object that returns a stdClass object on each iteration | |
foreach ($result as $record) { | |
// Perform operations on $record->title, etc. here. | |
// in this example the available data would be mapped to object properties: | |
// $record->nid, $record->title, $record->created | |
drupal_set_message("NID: $record->nid TITLE: $record->title CREATED: $record->created"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment