Establishment of sql table on magento



  • I need to set up a table in the database, but I can't. This is code :

    <?xml version="1.0" ?>
     <config>
         <modules>
             <DS_News>
                 <version>0.0.1</version>
             </DS_News>
         </modules>
    <frontend>
        <layout>
            <updates>
                <dsnews>
                    <file>ds_news.xml</file>
                </dsnews>
            </updates>
        </layout>
        <routers>
            <dsnews>
                <use>standard</use>
                <args>
                    <module>DS_News</module>
                    <frontName>news</frontName>
                </args>
            </dsnews>
        </routers>
    </frontend>
    <global>
        <models>
            <dsnews>
                <resourceModel>dsnews_resource</resourceModel>
            </dsnews>
            <dsnews_resource>
                <entities>
                    <table_news>
                        <table>ds_news_entities</table>
                    </table_news>
                </entities>
            </dsnews_resource>
        </models>
        <resources>
            <dsnews_setup>
                <setup>
                    <module>DS_News</module>
                </setup>
            </dsnews_setup>
        </resources>
    </global>
    

    I have a file. install-0.0.1.php

     <?php
           $installer = $this;
           $tableNews = $installer->getTable('dsnews/table_news');
           $installer->startSetup();
           $connection = $installer->getConnection();
           $installer->getConnection()->dropTable($tableNews);
           $table = $installer->getConnection()
            ->newTable($tableNews)
            ->addColumn('news_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
                'identity'  => true,
                'nullable'  => false,
                'primary'   => true,
                ))
            ->addColumn('title', Varien_Db_Ddl_Table::TYPE_TEXT, '255', array(
                'nullable'  => false,
                ))
            ->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
                'nullable'  => false,
                ))
            ->addColumn('created', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
                'nullable'  => false,
            ));
           $installer->getConnection()->createTable($table);
           $installer->endSetup();
    ?>
    

    Table core_resource I'm getting a line with an attribute. dsnews_setupbut I don't get the table.



  • What you got in the core_resource line with the attribute means that the installation crypt worked without error, which is likely to mean that the config.xml of the module. I'm assuming that magento lacks the definition and availability of DS_News_Model, DS_News_Model_Resource and DS_News_Model_Resource_Setup, which will report to the installor as they're handling your module

    <global>
        <models>
            <dsnews>
                <class>DS_News_Model</class>
                <resourceModel>dsnews_resource</resourceModel>
            </dsnews>
            <dsnews_resource>
                <class>DS_News_Model_Resource</class>
                <entities>
                    <table_news>
                        <table>ds_news_entities</table>
                    </table_news>
                </entities>
            </dsnews_resource>
        </models>
    </global>
    

    From all the information on magento I found online, I can recommend. https://wiki.magento.com/display/m1wiki/Create+a+custom+module+with+a+custom+database+table ♪ And, of course, read the originals. Good luck with magento!




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2