Can someone translate this syntax:

db_delete('artwork')
  ->condition('aid', $aids, 'IN')
  ->execute

into 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:

http://api.drupal.org/api/drupal/includes!database!query.inc/function/QueryConditionInterface%3A%3Acondition/7

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

nobody click here