Fastest way to get just one result from a database table in Drupal
Key words and phrases
db_fetch single result string from Drupal database db get one value short function to return one database data or, rather, datum db_result Drupal database query result fetch single resultTags
Description
To get a single value result – one row from a just one column – the Drupal function for that is db_result(), which takes the result of db_query() as an argument.
http://api.drupal.org/api/function/db_result/5
(The same function works for Drupals 4.7 and 6.)
So the fastest way to get a single result (please pardon the awkwardly named function) would look like this:
<?php
function field_placement_txt_field_get_cck($node_type, $txt_field_name) {
$cck = db_result(db_query("SELECT cck FROM {field_placement_txt_field} WHERE type = '%s' AND txt = '%s'", $node_type, $txt_field_name));
return $cck;
}
?>
Thanks, forgot the name of the function and here it is. Very relevant title for search engine :P.