Answer the question
In order to leave comments, you need to log in
How to properly initialize the database?
The essence of the task is to initialize the database, or rather the table ds_news_entities.
. I magento
'm working with for the first time, that's why there was a difficulty ( Full Release version - ver 1.9.2.4 ).
In the directory, I app/code/local/TestModule
create the directory of my module News
. Immediately, in the config , I app/code/local/TestModule/News/etc/config.xml
set the settings:
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<modules>
<TestModule_News>
<version>0.0.1</version>
</TestModule_News>
</modules>
</config>
app/etc/modules/TestModule_News.xml
:<?xml version="1.0" encoding="UTF-8" ?>
<config>
<modules>
<TestModule_News>
<active>true</active>
<codePool>local</codePool>
</TestModule_News>
</modules>
</config>
app/code/local/TestModule/News/sql
I create a subdirectory testmodulenews_setup
and in it the installation file install-0.0.1.php
:$installer = $this;
$installer->startSetup();
$installer->run("CREATE TABLE ds_news_entities (
`news_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`content` TEXT NOT NULL,
`created` DATETIME,
PRIMARY KEY (`news_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$installer->endSetup();
app/etc/modules/TestModule_News.xml
:<?xml version="1.0" encoding="UTF-8" ?>
<config>
<modules>
<TestModule_News>
<active>true</active>
<codePool>local</codePool>
</TestModule_News>
</modules>
<global>
<resources>
<testmodulenews_setup>
<setup>
<module>TestModule_News</module>
</setup>
</testmodulenews_setup>
</resources>
</global>
</config>
core_resource
corresponding to the name of the table being created. #0 /home/vitaliy/hosts/magento.dev/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array) #1 /home/vitaliy/hosts/magento.dev/lib/ Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #2 /home/vitaliy/hosts/magento.dev/app/code/core/Zend/Db/Statement.php(291 ): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3 /home/vitaliy/hosts/magento.dev/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array) #4 /home/vitaliy /hosts/magento.dev/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('CREATE TABLE ds...', Array) #5 /home/vitaliy/hosts/magento .dev/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('CREATE TABLE ds...', Array) #6 /home/vitaliy/hosts/magento.dev/lib /Varien/Db/Adapter/Pdo/Mysql.php(423):/home/vitaliy/hosts/magento.dev/lib/Varien/Db/Adapter/Pdo/Mysql.php(693): Varien_Db_Adapter_Pdo_Mysql->raw_query(' CREATE TABLE ds...') #8 /home/vitaliy/hosts/magento.dev/lib/Varien/Db/Adapter/Pdo/Mysql.php(675): Varien_Db_Adapter_Pdo_Mysql->multi_query('CREATE TABLE ds... ') #9 /home/vitaliy/hosts/magento.dev/app/code/core/Mage/Core/Model/Resource/Setup.php(932): Varien_Db_Adapter_Pdo_Mysql->multiQuery('CREATE TABLE ds...') #10 /home/vitaliy/hosts/magento.dev/app/code/local/TestModule/News/sql/testmodulenews_setup/install-0.0.1.php(17): Mage_Core_Model_Resource_Setup->run('CREATE TABLE ds... ') #11 /home/vitaliy/hosts/magento.dev/app/code/core/Mage/Core/Model/Resource/Setup.php(624): include('/home/vitaliy/h...') #12 /home/vitaliy/hosts/magento.dev/app/code/core/Mage/Core/Model/Resource/Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '0.0. 1') #13 /home/vitaliy/hosts/magento.dev/app/code/core/Mage/Core/Model/Resource/Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('0.0.1') #14 /home/vitaliy/hosts/magento.dev/app/code/core/Mage/Core/Model/Resource/Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates() #15 /home/vitaliy/hosts/magento.dev /app/code/core/Mage/Core/Model/App.php(428): Mage_Core_Model_Resource_Setup::applyAllUpdates() #16 /home/vitaliy/hosts/magento.dev/app/code/core/Mage/Core/Model /App.php(354): Mage_Core_Model_App->_initModules() #17 /home/vitaliy/hosts/magento.dev/app/Mage.php(683): Mage_Core_Model_App->run(Array) #18 /home/vitaliy/hosts/magento.dev/index.php(83): Mage::run('', 'store') #19 {main}errord
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question