2009年2月23日星期一

[fw-mvc] quote a string without the quote delimiters

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

没有评论: