[英]? instead of value with zend update
I'm trying to make updates querys with Zend_Db_Adapter but when I make an echo of the querys, the value that I want to update is still an "?". 我正在尝试使用Zend_Db_Adapter进行更新查询,但是当我对查询进行回显时,我要更新的值仍然是“?”。 I check the value $foo, I always have 1 or 0 My code :
我检查值$ foo,我总是有1或0我的代码:
$this->_db->beginTransaction();
try {
foreach($a_result as $k => $j){
$foo = ($j['val1'] >= $j['val2']) ? 1 : 0 ;
$a_data = array('bar' => $foo);
$where['id = ?'] = $k;
$update = $this->_db->update($this->_name, $a_data, $where);
}
$this->_db->commit();
} catch (Exception $e) {
$this->_db->rollBack();
echo $e->getMessage();
}
All my querys looks like this : 我所有的查询如下:
foo
SET bar
= ? foo
SET bar
=? WHERE (id = 39) foo
SET bar
= ? foo
SET bar
=? WHERE (id = 40) This code works for me, try to put it inside your loop and see if it helps :) 该代码对我有用,请尝试将其放入循环中,看看是否有帮助:)
$a_data = array(
'bar' => $foo
);
$_where = array();
$_where[] = "id = '" . $k . "'";
Besides that, I think your problem resides in the $where, it's written in a strange way. 除此之外,我认为您的问题出在$ where上,它的编写方式很奇怪。 I usually use, for selects
我通常使用,供选择
->where('ID = ? ', $k)
In your case I would use 在你的情况下,我会用
$where = $this->_yourTable->getAdapter()->quoteInto('id = ?', $id)
Anyway, the first one should be simpler! 无论如何,第一个应该更简单!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.