Pregunta

I just want to update a column of type text and set it to empty, but the Apache error log says: PHP Catchable fatal error: Argument 2 passed to Zend_Db_Adapter_Abstract::update(), here's the code:

public function setDbTable($dbTable) {
    if (is_string($dbTable)) {
        $dbTable = new $dbTable();
    }
    if (!$dbTable instanceof Zend_Db_Table_Abstract) {
        throw new Exception('Invalid table data gateway provided');
    }
    $this->_dbTable = $dbTable;
    return $this;
}

public function getDbTable() {
    if (null === $this->_dbTable) {
        $this->setDbTable('Application_Model_DbTable_Blog');
    }
    return $this->_dbTable;
}

public function removeFilename($imageId){
    $data = array('filename' => '');
    $where = $this->getDbTable()->getAdapter()->quoteInto('imageid = ?', $imageId);
    $this->getDbTable()->getAdapter()->update($data,$where);
}

I tried anything, but nothing is updated. Also this piece of code:

$this->getDbTable()->getAdapter()->update(array('filename' => '',array('imageid = ?' => $imageId);

but this throws an execption. What could be the problem? Any help is welcome.

¿Fue útil?

Solución

Use Zend_Db_Table_Abstract::update(), not Zend_Db_Adapter_Abstract::update():

$this->getDbTable()->update($data,$where);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top