2009年5月27日星期三

[fw-db] Zend_Db_Table_Abstract delete IN

Hi people.

I have this method in my model, it receives an id and array of integers
contentIds


/**
* Delete contents by FeedId and content ids.
*
* @param int $feedId
* @param arrat $contentIds
* @return int number of deleted rows
*/
public function deleteBulk($feedId, array $contentIds) {
return $this->delete(
$this->getAdapter()->quoteInto('FeedId = ?', $feedId) .
' AND ContentId IN (' . implode(',', $contentIds) . ')');
}

gives

DELETE FROM `Content` WHERE (FeedId = 1 AND ContentId IN
(179218,179217,179216,179215))

This works ok, but is not safe. When I do

/**
* Delete contents by FeedId and content ids.
*
* @param int $feedId
* @param arrat $contentIds
* @return int number of deleted rows
*/
public function deleteBulk($feedId, array $contentIds) {
return $this->delete(
$this->getAdapter()->quoteInto('FeedId = ?', $feedId) .
' AND ContentId IN (' . $this->getAdapter()->quote(implode(',',
$contentIds)) . ')');
}

or something similar, instead getting

DELETE FROM `Content` WHERE (FeedId = 1 AND ContentId IN
('179218,179217,179216,179215'))

and delete nothing from table.

Where am I doing it wrong.

Regards,
Sasa Stamenkovic
--
View this message in context: http://www.nabble.com/Zend_Db_Table_Abstract-delete-IN-tp23745710p23745710.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: