【问题标题】:Zend db table - save() not savingZend db 表 - save() 不保存
【发布时间】:2011-12-06 10:51:27
【问题描述】:

我无法更新表中的条目。我使用的代码如下:

class Model_Notification extends Zend_Db_Table_Abstract
{
    protected $_name = "notifications";
    public function encrypt($id,$key)
    {
        $select = $this->select();
        $select->where('id = ?', $id);
        $row = $this->fetchRow($select);

        if( $row )
        {
            $row->key = $key;
            $row->save();
            return true;
        }
        return false;

    }
}

一开始我以为可能是列名“key”,于是改成了“passkey”,但没有成功。我越来越真实,每次都回到我身边!

我仍然可以添加/删除表格,但我无法理解为什么此更新save() 不起作用!

干杯,

【问题讨论】:

    标签: mysql zend-framework


    【解决方案1】:

    试试这个:

    $数据 = 数组( “字段1”=>“值1”, “字段2”=>“值2” ); $哪里=“id=”。 $id; $table = 新表(); $table->update($data, $where);

    【讨论】:

      【解决方案2】:

      更优化的方式

      $table = new Table();
      $data = array(
          "field1" => "value1",
          "field2" => "value2"
      );
      $where = $table->getAdapter()->quoteInto("id = ?",$id);
      
      
      $table->update($data, $where);
      

      【讨论】:

        猜你喜欢
        • 2018-11-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-25
        • 1970-01-01
        • 2017-01-16
        • 2013-09-24
        • 2018-01-04
        相关资源
        最近更新 更多