2012-07-10 103 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