Zendframework更新查询无法正常工作

时间:2012-10-16 07:17:03

标签: zend-framework

我无法找到我的查询无效的原因

 $data['active']=1
 $bind=$this->_db->quoteInto('id = ?', $id);
 $returnval= $this->_db->update($this->_name,$data,$bind);

`UPDATE `discount_rule` SET `isActive` = ? WHERE (rule_id = 20)`

为什么“?” !我尝试了很多方法,但我无法以这种方式实现。$ this_db是Zend_DB_Adapter_abstract类型。要么是愚蠢的错误,要么我无法理解如何使用Zend_Db_Table_Abstract - update()!。

更多详情

class demo_Model_price extends Zend_Db_Table_Abstract{
      public function update($data,$id){
        $where='id ='.$id; //i changed it to see if this work 
        try{
           $returnval= $this->update($this->_name,$data,$where);
           return $returnval;
        }catch(Exception $e)
        {
            echo $e->getMessage();
        }
     }
}

有人可以在我的查询中识别出错误吗?这是一个简单的查询,它应该可以工作。

1 个答案:

答案 0 :(得分:0)

希望您使用Models

一些一般性观点

始终以大写Demo_Model_price

开始上课

update是一个关键字为zend

的函数

尝试以下代码

class Demo_Model_price extends Zend_Db_Table_Abstract{
      public function updateData($data,$id){
        $where = $this->getAdapter()->quoteInto('id = ?',$id);
        try{
           $returnval= $this->update($data,$where);
           return $returnval;
        }catch(Exception $e)
        {
            echo $e->getMessage();
        }
     }

}

相关问题