使用Zend Framework,有没有办法使用quoteInto方法将多个条件传递给update语句?我发现了一些这个问题的引用,但是我正在寻找支持的方式,而不必扩展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);
参考
> http://blog.motane.lu/2009/05/21/zend_db-quoteinto-with-multiple-arguments/
> http://codeaid.net/php/multiple-parameters-in-zend_db::quoteinto%28%29
最佳答案
您可以为$ 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);
相关文章
- php - 具有Zend_Db的复合WHERE子句使用多个AND运算符
- php - 如何在Zend Framework中使用预处理语句
- php - 没有Zend Framework的Zend_Db
- zend-framework - Zend_db缓存
- 如何使用zend-framework应用条件样式表$this-> headLink() - > appendStylesheet('css/css.css')
- php - 如何使用Zend_Db添加多行?
- zend-framework - 如何在AND条件内写入带有OR条件的Zend db select
- zend-framework - Zend DB更新中的OR子句?
转载注明原文:zend-framework – 如何在Zend_Db和QuoteInto的更新语句中使用多个条件 - 代码日志