Hello everyone.
Can anyone explain me what the mistake I did in the query? I'm trying to use Drupal 7 database API.
Here is a problematic source code written according to dynamic queries api:
function product_load($nodes) {
// This is a query which I use instead of broken one.
$result = db_query(
"SELECT nid, body, short_description, price
FROM {product} p
WHERE p.nid IN (:nids)",
array(':nids' => array_keys($nodes)));
// This query is not working well for some reason. It is made in familiar way for Drupal 7...
$result = db_select('product', 'p')
->condition('nid', array_keys($nodes), 'IN')
->execute();
// Extract data.
foreach ($result as $record) {
// Fill $nodes object...
$nodes[$record->nid]->body = $record->body;
}
}
Below you can look at the quotation of the error message which I receive after the broken query execution. It seems to me that SELECT has no any mistakes in its syntax. Possibly I simply don't see it.