我在api中使用此查询
if (isset($json['version'])) {
$client_cache_version = @$json['version'];
$version_sql = $db->quoteInto("SELECT max(messageVersion) as version FROM messageTable");
$version_results = $db->fetchAll($version_sql);
$version_array = $version_results['0'];
$max_version = $version_array['version'];
if($max_version > $client_cache_version){
$sql = $db->quoteInto("SELECT * FROM messageTable");
$results = $db->fetchAll($sql);
$count = array(
'count' => sizeof($results)
);
所有代码都正常工作但
中存在问题$version_sql = $db->quoteInto("SELECT max(messageVersion) as version FROM messageTable");
当我尝试在curl上检查此代码时出现此错误
Warning: Missing argument 2 for Zend_Db_Adapter_Abstract::quoteInto()
我知道在Using quoteInto()
的情况下需要多个参数,但我现在没有多个参数,所以我可以做什么?
答案 0 :(得分:2)
来自Db_Adapter_Pdo_Mysql::quoteInto()
上的Zend API:
占位符是一个问号;所有占位符都将替换为引用值。例如:
$text = "WHERE date < ?";
$date = "2005-01-02";
$safe = $sql->quoteInto($text, $date);
// $safe = "WHERE date < '2005-01-02'"
-
Parameters Name Type Description $text string The text with a placeholder. $value mixed The value to quote. $type string OPTIONAL SQL datatype $count integer OPTIONAL count of placeholders to replace Returns Type Description string An SQL-safe quoted value placed into the original text.
请注意,该值为REQUIRED。如果你没有约束任何参数,你不应该使用这种方法。