什么';Zend中的quote和quoteInto之间的区别是什么


What's the difference between quote and quoteInto in Zend?

我不知道quoteInto与quote有什么不同。

quoteInto()用于为sql查询准备数据。quote()函数只引用可能终止字符串文字的内容,如'、"、''0等。

$sql = 'SELECT * FROM users WHERE enabled = ? AND country = ?';
$sql = $users->getAdapter()->quoteInto($sql, 1);
$sql = $users->getAdapter()->quoteInto($sql, 'UK');
//SELECT * FROM users WHERE enabled = 1 AND country = 'UK'
print $db->quote("%some'stuff%") . "'n"; 
// Output: '%some''stuff%' 

我不认为quoteInto()是最好的解决方案,因为它只转义特殊字符,并在其周围应用引号。转义通常有几个问题,例如,你必须有所用DBMS的规范字符列表并维护这个列表-你怎么知道Zend有这个DBMS列表100%完美??在我看来,只有一个真正安全的解决方案->使用参数化查询。