I am running this code and it worked for me but added error in error log

$installer = new Mage_Core_Model_Resource_Setup();

         DROP TABLE IF EXISTS {$installer->getTable('test')};
         CREATE TABLE {$installer->getTable('test')} (
                        ci tinyint(3) unsigned NOT NULL auto_increment,
                        cc char(2) NOT NULL,
                        cn varchar(50) NOT NULL,
                        PRIMARY KEY (ci)
                        ) AUTO_INCREMENT=1 ;


but is generating error in error log.

Warning: Missing argument 1 for Mage_Core_Model_Resource_Setup::__construct(), called in /opt/lampp/htdocs/magento_9_1_3/app/code/local/Namespace/Modulename/controllers/Adminhtml/tesController.php on line 512 and defined in /opt/lampp/htdocs/magento_9_1_3/app/code/core/Mage/Core/Model/Resource/Setup.php on line 127 2017-01-09T12:49:41+00:00 ERR (3): Notice: Undefined variable: resourceName in /opt/lampp/htdocs/magento_9_1_3/app/code/core/Mage/Core/Model/Resource/Setup.php on line 130

any idea how remove this error?

2 Answers 2


The constructor method for Mage_Core_Model_Resource_Setup defines a single parameter which is required to create an object instance:

public function __construct($resourceName) {...}

The $resourceName parameter is declared as:

@param string $resourceName the setup resource name

You can find the setup resource name in the <global> section your module's config.xml file:


So, the $resourceName parameter should be 'namespace_modulename_setup' in your case:

$installer = new Mage_Core_Model_Resource_Setup('namespace_modulename_setup');

Give it a try. I may be wrong, in which case I'll remove this answer.

Note: module setup code is normally run automatically when a module is first installed or when it's upgraded to a new version. Magento takes care of this for you, so it's not usually necessary to run setup code from within a controller class. The purpose of a controller is to interact with frontend URL requests. They are responsible for loading layouts, doing redirects, sending AJAX responses, etc. Using controllers to execute setup scripts kind of goes against the MVC pattern.

Thanks, D-man


Setup model is trying to install/upgrade some module in your install script. cannot find a write connection for the resource. It seems issue in defining config.xml of your module

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.