2011-12-06 144 views
0

我使用此查詢的APIzend框架中的quoteInto的替代?

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"); 

當我嘗試檢查捲曲這個代碼,我得到這個錯誤

Warning: Missing argument 2 for Zend_Db_Adapter_Abstract::quoteInto() 

我知道在Using quoteInto()的情況下多個參數是需要的,但我現在沒有多個參數,所以我可以做什麼?

+0

http://framework.zend.com/manual/en/zend.db.adapter.html#zend.db.adapter.quoting.quote-into。我不明白你爲什麼使用這個功能。 – legiero

+0

@legiero :)我有這個鏈接,我已經研究確定,所以任何備選方案,這是不工作的單參數 – John

回答

2

Zend APIDb_Adapter_Pdo_Mysql::quoteInto()

該佔位符是一個問號;所有佔位符將被替換爲引用的值。例如:

$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. 

注意該值是必需的。如果你沒有綁定任何參數,你不應該使用這種方法。

+0

:)是的,我知道,謝謝,但我想知道我能做什麼在我的情況:)乾杯 – John

+0

真的嗎?完全跳過你的方法,只是將查詢傳遞給'fetchAll()'。你懂你的代碼嗎? –