0

I cannot update an entry in my table. The code I am using is below:

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;

    }
}

At first, I thought it might be the column name "key", so I changed it to "passkey" but no success. I am getting true returned to me every time!

I can still add/delete to the table, but I canon understand why this update save() does not work!

Cheers,

2 Answers 2

2

Try this:

$data = array(
    "field1" => "value1",
    "field2" => "value2"
);
$where = "id = " . $id;

$table = new Table();
$table->update($data, $where);
Sign up to request clarification or add additional context in comments.

Comments

1

The more optimised way

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


$table->update($data, $where);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.