$idArray = array(23,43,12);
$sql = "DELETE FROM articles where id IN (" . $db->quote($idArray) . ")";
echo $sql; // prints "DELETE FROM articles where id IN (23, 43, 12)"
-Hector
On Mon, Feb 23, 2009 at 6:17 PM, Van H Tran <tvhoang1980@yahoo.com> wrote:
Hi all,
This is what it says about Zend_Db_Adapter quote function:
http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.quoting
Note that the return value of
quote()
includes the quote delimiters around the string. This is different from some functions that escape special characters but do not add the quote delimiters, for example mysql_real_escape_string().
So if I have
$idList = implode (',', $idArray)
then how do I quote this string $idList (of the form, say, "(23,43,12)") to do this query
$sql = "DELETE FROM articles where id IN " . $db->quote($idList);
it will be come
DELETE FROM articles where id IN ('23,43,12')
This is obviously wrong.
How can I fix this problem with Zend? I don't want to use mysql_real_escape_string() or any non-Zend other function
Thanks,
Hoang
没有评论:
发表评论