使用Zend Framework,有没有办法使用quoteInto方法将多个条件传递给更新语句?我发现了一些对这个问题的引用,但我正在寻找一种支持的方式,而不必扩展Zend_Db或没有连接。
$db = $this->getAdapter();
$data = array('profile_value' => $form['profile_value']);
$where = $db->quoteInto('user_id = ?', $form['id'])
. $db->quoteInto(' AND profile_key = ?', $key);
$this->update($data, $where);
参考
答案 0 :(得分:21)
您可以为array
参数使用$where
类型。元素将与AND
运算符结合使用:
$where = array();
$where[] = $this->getAdapter()->quoteInto('user_id = ?', $form['id']);
$where[] = $this->getAdapter()->quoteInto('key = ?', $key);
$this->update(array('value' => $form['value']), $where);
答案 1 :(得分:15)
从1.8开始,您可以使用:
$where = array(
'name = ?' => $name,
'surname = ?' => $surname
);
$db->update($data, $where);
答案 2 :(得分:-2)
刷新上述答案
$data = array('value' => $form['value']);
$where = array();
$where[] = $this->getAdapter()->quoteInto('user_id = ?', $form['id']);
$where[] = $this->getAdapter()->quoteInto('key = ?', $key);
$this->update($data, $where);