0

I develop a module with custom connection to custom database, and i'm using it through Mage_Core_Model_Abstract, Collection etc. But in exception.log i see

Exception message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbname.table_prefix_tablename' doesn't exist

But my custom db doesn't have a table prefix. I've tryed to override table_prefix

<global>
<resources>
<db><table_prefix><![CDATA[]]></table_prefix></db>
<customdb_write>
...

but it doesn't work. What can i do?

1 Answer 1

2

try write install script

$installer = $this;
/* @var $installer Mage_Core_Model_Resource_Setup */

$installer->startSetup();

$installer->run("
  CREATE TABLE IF NOT EXISTS {$this->getTable('test')} (
  `language_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `country` varchar(255) NOT NULL DEFAULT '',
  `language` varchar(255) NOT NULL,
  `description`varchar(255) NOT NULL,
  PRIMARY KEY (`language_id`),
  UNIQUE KEY `locale` (`country`,`language`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
");
$installer->endSetup();
8
  • but i'm working with a custom db. I don't need alter tables
    – giovanni
    Commented Feb 6, 2014 at 10:08
  • you put create table syntax. it simple
    – Keyul Shah
    Commented Feb 6, 2014 at 10:09
  • See I update my code
    – Keyul Shah
    Commented Feb 6, 2014 at 10:11
  • i see, and so this installer writes in my custom db through config.xml connection?
    – giovanni
    Commented Feb 6, 2014 at 10:20
  • yes that way. :)
    – Keyul Shah
    Commented Feb 6, 2014 at 11:11

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.