2011-07-03 42 views
2

我在更新行时遇到了一些麻烦。Zend_Db_Adapter_Abstract :: update()必须是数组

我的类扩展Zend_Db_Table_Abstract

这里是我的代码:

return $this->update(
      array('data' => $data), 
      $this->getAdapter()->quoteInto("id = ?", $id) 
     ) ? true : false; 

我不断收到唯一的例外是: PHP Catchable fatal error: Argument 2 passed to Zend_Db_Adapter_Abstract::update() must be an array, string given, called in /Applications/MAMP/htdocs/app/library/Session/Handler.php on line 51 and defined in /Applications/MAMP/libraries/zend-framework/ZendFramework-1.11.3-minimal/library/Zend/Db/Adapter/Abstract.php on line 587

我试图传递一个阵列,但也没有任何反应。任何想法?!

回答

0

你可能在第二参数中使用阵列 - >更新()

例如:

$this->update(
    array('data' => $data), 
    array("id = ?" => $id), 
) ? true : false; 

但字符串必须是确定

becouse

/** 
* Convert an array, string, or Zend_Db_Expr object 
* into a string to put in a WHERE clause. 
* 
* @param mixed $where 
* @return string 
*/ 
protected function _whereExpr($where) 
{ 
    if (empty($where)) { 
     return $where; 
    } 
    **if (!is_array($where)) {** 
     $where = array($where); 
    }