2012-07-10 106 views
0

我不知道發生了什麼與此更新呼叫丟失,這是我的代碼:Zend的DB更新值未設置

$table = new Application_Model_DbTable_ProductContaminant(); 
$db = $table->getAdapter(); 

$db->getProfiler()->setEnabled(true); 
$data = array('value' => '999'); 
$where[] = $db->quoteInto('product_id = ?', $q['product_id']); 
$where[] = $db->quoteInto('contaminant_id = ?', $k); 
$table->update($data, $where); 

print $db->getProfiler()->getLastQueryProfile()->getQuery(); 

和所述輪廓輸出爲:

UPDATE `product_contaminants` SET `value` = ? WHERE (product_id = '4802') AND (contaminant_id = 69) 

爲什麼不'值'被填充?

回答

2

值未填充,因爲getQuery將只返回帶有參數佔位符的預準備語句。如果你想使用的參數時,它更新試試這個:

$db->getProfiler()->getLastQueryProfile()->getQueryParams() 

更多信息here

+0

好的,這似乎是正確的:[1] => 999.爲什麼它沒有進入聲明? – rladd 2012-07-10 19:25:40

+0

當然,你不能更新一個空行,你可以嗎?謝謝你的幫助Tim! – rladd 2012-07-10 19:57:37