Posted by jmm42 on January 13, 2013 at 12:42am
Can someone translate this syntax:
db_delete('artwork')
->condition('aid', $aids, 'IN')
->executeinto an equivalent SQL command syntax?
This is my interpretation:
DELETE FROM {artwork} WHERE (aid = $aid)
Or, would it be:
DELETE FROM {artwork} WHERE aid IN ($aids)
But, I'm kind of confused with the 'IN' parameter.
Comments
Not the former
Based on: http://drupal.org/node/310081, the former is incorrect.
From:
I am confident that the latter is correct based on the API:
However, may be 'slightly' off. It can be verified by issuing the following line:
print (string)$query;in place of:
->execute();As suggested by - http://tiger-fish.com/blog/drupal-7-debugging-sql-queries
$aids is an array (it should
$aids is an array (it should be when you are using it with IN, or else a simple = can be used).
If $aids is this:
$aids = array(1, 30, 432);?>
Then the so called translated query would be:
<code>DELETE FROM {artwork} WHERE aid IN (1, 30, 432)
Which means delete when the aid is either 1, 30 or 432.
Jaypan We build websites