0

Does anyone know, if there is a bug in CRUD in delete operations. DB Adapter:

$this->_db = Zend_Registry::get("db");

I do like this:

$sql = "DELETE FROM premium_items WHERE id = '$id'";
                    $stmt = new Zend_Db_Statement_Pdo($this->_db, $sql); 
                    return $stmt->execute();

and

$sql = "DELETE FROM premium_items WHERE id = ?";
                $stmt = new Zend_Db_Statement_Pdo($this->_db, $sql); 
                return $stmt->execute(array($id));

and

$this->_db->delete('premium_items', "id = '$id'");

Each variant works without any errors but does not do what it has to do. What can I do in such situation ?

2 Answers 2

1

With a Zend_Db_Adapter, try:

$this->_db->delete('premium_items', array("id = ?" => $id));

or, in this particular case you can do:

$this->_db->delete('premium_items', 'id = ' . (int)$id);

(but only do this one if you're using an integer and you cast it!)

Sign up to request clarification or add additional context in comments.

1 Comment

Found the solution, everybody was right, one just always has to check if the transaction is committed :(
1

In your model (Zend_Db_Table_Abstract):

$row = $this->find($id)->current();
$row->delete();

Or

$db = $this->getAdapter();
$db->delete($table, $db->quoteInto("id = ?", $id));

2 Comments

I actually have this already: public function __construct(Zend_Db_Table_Abstract $dbTable, $id) { $this->_dbTable = $dbTable; if ($id) { $this->_row = $this->_dbTable->find($id)->current(); } else { $this->_row = $this->_dbTable->createRow(); } } then public function delete() { return $this->_row->delete(); }
I already had this probleme, without find any solution with zend_db_table function.. I solve this with my last code

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.