I have Model class which extends Mage_Core_Model_Abstract. I have a resource which extends Mage_Core_Model_Mysql4_Abstract. Now I am deleting from controller with the following code:
public function deleteAction()
{
$params = $this->getRequest()->getParams();
$blogpost = $this->_createModel();
$blogpost->setId($params['id']);
$blogpost->delete();
echo 'Post with id ' . $params['id'] . ' is deleted';
}
The problem is there is no error shown when I supply non existing ids. What to do ? Do I have to load that id and check whether it exists or not? or should I use the try/catch. I used try and catch but did not give any results.
Of course it does not throw an exception, the
DELETEstatement gets executed without errors eventually, it only has an affected row count of 0.Unfortunately the row count gets lost here (
Mage_Core_Model_Resource_Db_Abstract):because the return value of
_getWriteAdapter()->delete()is not used anywhereIt looks like you will indeed have to load your model before deleting it, or at least check for its existence via the ressource collection.