You are here

db_query in Drupal 7

Wiki Terms: 

Here's a linkback for a nice guy who's made a db_query cheat sheet for Drupal 7.

http://www.drupaler.co.uk/blog/drupal-7-cheat-sheet-database/493

Also here is a simple drupal 7 query:

$dbresult = db_query("SELECT n.nid from {node} n where NOT EXISTS (SELECT t.entity_id from {field_data_field_tempo} t where t.entity_id = n.nid) and n.type = 'page';");
		foreach($dbresult as $row){
	      $theanswer[] = $row->nid;
		}

notice an object is returned and not an associative array like in drupal 6
also no drupal_fetch_object, you just loop through the object with a foreach loop.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer