D
D
Denis99992017-09-05 20:46:28
Magento
Denis9999, 2017-09-05 20:46:28

Table not being created in database with Magento installer file?

config.xml

<?xml version="1.0" ?>
<config>
    <modules>
        <My_Articles>
            <version>1.0.0</version>
        </My_Articles>
    </modules>

    <frontend>
        <routers>
            <marticles>
                <use>standard</use>
                <args>
                    <module>My_Articles</module>
                    <frontName>articles</frontName>
                </args>
            </marticles>
        </routers>
    </frontend>
    <global>


        <myarticles_recource>
            <class>My_Articles_Model_Resource</class>
            <entities>
                <table_myarticles>
                    <table>my_articles</table>
                </table_myarticles>
            </entities>
        </myarticles_recource>
    </global>

</config>

install-1.0.0.php:
<?php
die('Setup');
$installer = $this;
$installer->startSetup();
$installer->run("CREATE TABLE my_articles (
      `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
      `title` VARCHAR(255) NOT NULL,
      `header_h1` VARCHAR(255) NOT NULL,
      `meta_tag_keywords` VARCHAR(255) NOT NULL,
      `meta_tag_description` VARCHAR(255) NOT NULL,
      `image` VARCHAR(255) NOT NULL,
      `preview` TEXT NOT NULL,
      `content` TEXT NOT NULL,
      `created` DATETIME,
      PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$installer->endSetup();

Location of files and names of directories:
9fc3dbf1333941399f1644cb62c4dc0a.png
I'm following the tutorial, but the code from there doesn't work. I think the problem is most likely due to the incorrect name of the marticles_setup directory. Yes, die() should be displayed in this case.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
imdeveloper, 2017-09-06
@Denis9999

Because the Global section does not indicate that you are going to install something.
You need to add something like this to the Global section

<resources>  
        <myarticles_setup>
            <setup>
                <module>My_Articles</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </myarticles_setup>
        <myarticles_write>
            <connection>
                <use>core_write</use>
            </connection>
        </myarticles_write>
        <myarticles_read>
            <connection>
                <use>core_read</use>
            </connection>
        </myarticles_read>
    </resources>

Then rename the install folder from marticles_setup to myarticles_setup

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question