How can I get count of deleted rows after db_delete
?
db_delete('node')
->condition('uid', 1)
->execute();
something like
$count = db_delete('node')
->condition('uid', 1)
->execute()->columnCount();
doesn't work
The delete query will return a query object for all methods except ->execute(). Methods can be chained until the query has been assembled. Execute() completes the chain.
Try:
$count = db_delete('node')
->condition('uid', 1)
->execute();
You can get count of deleted rows as follow:
db_delete('node')
->condition('uid', 1)
->execute();
$count = db_query('SELECT ROW_COUNT()')->fetchField();
print($count);
Next expression works:
$count= db_delete('node')
->condition('uid', 1)
->execute();
dpm($count);
db_delete returns count of deleted rows after execution.