I am trying to perform a db_query
but am unable to do so.
The query I am trying to perform is very simple, but to make things even simpler, the following query does not even work for me:
$result = db_query('SELECT name FROM users WHERE uid = 1');
and if I do:
echo (string)$result->name;
nothing is displayed.
Does anyone know what could be causing this?
Edit - Updated with new code:
define('DRUPAL_ROOT', getcwd());
$_SERVER['REMOTE_ADDR'] = "localhost";
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$result = db_query('SELECT OFFICE_ID FROM {OFFICE}');
$counter = 0;
foreach($result as $record) {
$counter = $counter + 1;
print $record->office_id;
}
print $counter;
Nothing will be printed, but at the end of the loop, the number of loops performed is the same as the number of rows returned from a direct query on the DB itself.