Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9175745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:58:04+00:00 2026-06-17T16:58:04+00:00

I have Model class which extends Mage_Core_Model_Abstract . I have a resource which extends

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:58:05+00:00Added an answer on June 17, 2026 at 4:58 pm

    Of course it does not throw an exception, the DELETE statement 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):

    /**
     * Delete the object
     *
     * @param Varien_Object $object
     * @return Mage_Core_Model_Resource_Db_Abstract
     */
    public function delete(Mage_Core_Model_Abstract $object)
    {
        $this->_beforeDelete($object);
        $this->_getWriteAdapter()->delete(
            $this->getMainTable(),
            $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId())
        );
        $this->_afterDelete($object);
        return $this;
    }
    

    because the return value of _getWriteAdapter()->delete() is not used anywhere

    It looks like you will indeed have to load your model before deleting it, or at least check for its existence via the ressource collection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class which extends a JPanel. Code below: public class Test extends
I have the following code for ExtendableListAdapter class which extends to BaseExpandableListAdapter. I am
i have a class User which extends Ebean Model. And i defined a dbfile
I have a simple model class (Part), which pulls from it's information from a
I have the following model class Comment extends AppModel { var $useTable = comments;
Here is my model_users class (the model it extends from doesn't have anything yet
I have simple item model with name and quantity: public class Item extends CouchDbDocument{
in my zf application i have base model class Application_Model, which connects to db
I have a Query model: class Query < ActiveRecord::Base belongs_to :test end which is
I have a model in my rails application which is class Person < ActiveRecord::Base

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.