久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從 magento 模塊創(chuàng)建一個新表

Create a new table from magento module(從 magento 模塊創(chuàng)建一個新表)
本文介紹了從 magento 模塊創(chuàng)建一個新表的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試使用一個管理模塊在數據庫中創(chuàng)建一個新表.我的設置

I am trying to have an admin module I am working on create a new table in the database. What I have setup in

app/code/local/Foo/BAR/sql/mysql4-install-0.1.0.php

app/code/local/Foo/BAR/sql/mysql4-install-0.1.0.php

<?php
  $installer = $this;
  $installer->startSetup();

  $installer->run("
    DROP TABLE IF EXISTS {$this->getTable('notes')};

    CREATE TABLE {$this->getTable('notes')} (
      `ppr_id` int(11) NOT NULL AUTO_INCREMENT,
      `notesku` bigint(20) NOT NULL,
      `notestatus`  smallint(16),
      PRIMARY KEY (`notes`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8
  ");

  $installer->endSetup();

這個在 app/code/local/Foo/BAR/etc/config.xml

and this in app/code/local/Foo/BAR/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Foo_BAR>
            <version>0.1.0</version>
        </Foo_BAR>
    </modules>    

    <global>
            <models>
                <BAR>
                    <class>Foo_BAR_Model</class>
                    <resourceModel>BAR_mysql4</resourceModel>
                </BAR>

                <BAR_myslq4>
                    <class>Foo_BAR_Model_Mysql4</class>
                    <entities>
                        <BAR>
                            <table>notes</table>
                        </BAR>
                    </entities>
                </BAR_myslq4>           
            </models>

            <resources>
                <BAR_setup>
                    <setup>
                        <module>Foo_BAR</module>
                    </setup>
                    <connection>
                        <use>core_setup</use>
                    </connection>
                </BAR_setup>
                <BAR_write>
                    <connection>
                        <use>core_write</use>
                    </connection>
                </BAR_write>
                <BAR_read>
                    <connection>
                        <use>core_read</use>
                    </connection>
                </BAR_read>
            </resources>
    </global>    

    <admin>
        <routers>
            <BAR>
                <use>admin</use>
                <args>
                    <module>Foo_BAR</module>
                    <frontName>bar</frontName>
                </args>
            </BAR>      
        </routers>
    </admin>



      <adminhtml>
        <menu>
            <catalog>
                <children>
                     <BAR_menu translate="title" module="BAR">
                        <title>BAR</title>
                        <children>
                            <list translate="title" module="BAR">
                                <title>Bar</title>
                                <action>bar/index/index</action>
                            </list>                       
                        </children>
                    </BAR_menu>
                </children>
            </catalog>
        </menu>
    </adminhtml>       
</config>

我使用的案例與我的公司大寫且模塊名稱全部大寫的示例相匹配.我在想也許這讓我絆倒了?我的理解是,一旦我運行點擊該模塊的頁面,它將觸發(fā)該 mysql 以創(chuàng)建表.那是對的嗎?還有什么我應該做的嗎?

The case I am using matches this example where my company is capitalized and the module name is all uppercase. I am thinking maybe that is tripping me up? My understanding is that once I run the page that hits that module it will trigger that mysql to create the table. Is that correct? Is there something else I should be doing?

我非常感謝您對此的任何幫助.

I greatly appreciate any help with this.

推薦答案

如果安裝/升級腳本未運行,請檢查以下事項:

If a setup/upgrade script isn't running, here are some things to check:

  1. Magento 是否正在加載您的模塊?轉到系統 > 配置 > 高級 > 高級,然后查看您的模塊是否出現在禁用模塊輸出"列表中.如果沒有,則 Magento 根本不會加載您的模塊,因此不會運行任何安裝腳本.正如 Cags 在他的評論中指出的那樣,如果您尚未創(chuàng)建模塊,您將需要 app/etc/modules 中的一個 xml 文件來告訴 Magento 加載您的模塊.

  1. Is Magento loading your module? Go to System > Configuration > Advanced > Advanced and see if your module appears in the "Disable Module Output" list. If it doesn't, Magento isn't loading your module at all, and therefore won't run any setup scripts. As Cags noted in his comment, you'll need an xml file in app/etc/modules to tell Magento to load your module if you haven't already created one.

確保您的資源在 config.xml 文件中的正確位置聲明.它們應該在 <global> 標簽內(這在您的情況下似乎是正確的).

Make sure your resources are declared in the correct place in the config.xml file. They should be inside the <global> tag (this appears to be correct in your case).

確保您的安裝文件位于正確的位置.它們應該位于模塊內的 sql/文件夾中.我認為這是你的問題,這個例子中的安裝文件應該是 app/code/local/Foo/BAR/sql/BAR_setup/mysql4-install-0.1.0.php

Make sure your setup files are in the correct location. They should be in a sql/ folder inside your module. I think this is your problem, the setup file in this example should be app/code/local/Foo/BAR/sql/BAR_setup/mysql4-install-0.1.0.php

檢查完以上所有內容后,如果您有一個用于調試的 IDE(并且如果您正在做任何嚴肅的 Magento 工作,請幫自己一個忙并獲得一個),在設置中設置一個斷點文件并確保它被命中.

Having checked all of the above, if you have an IDE set up for debugging (and if you're doing any serious Magento work, do yourself a favor and get one up), set a breakpoint in the setup file and make sure it's being hit.

檢查數據庫中的 core_resource 表中的 BAR_setup 條目.如果它在那里,Magento 已經運行了一次安裝腳本并且不會再次運行它.如果您需要再次運行安裝腳本,請刪除此記錄.同樣,如果您需要重新運行升級腳本,您可以更改版本號(但請確保您了解第二次運行安裝/升級腳本的后果).

Check the core_resource table in the database for a BAR_setup entry. If it's there, Magento has run the setup script once and won't run it again. If you need to run your setup script again, delete this record. Likewise you can change the version numbers if you ever need to re-run upgrade scripts (but make sure you understand the consequences of running setup/upgrade scripts a second time if you do).

如果所有其他方法都失敗,請查看 Alan Storm 的 Magento 安裝腳本調試指南.

If all else fails check out Alan Storm's guide to debugging Magento setup scripts.

這篇關于從 magento 模塊創(chuàng)建一個新表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 国产精品精品视频一区二区三区 | 久久逼逼 | 国产精品一区二区三 | 国产日韩欧美在线播放 | av网站免费观看 | 日韩a在线观看 | 天天看天天干 | 久久综合狠狠综合久久综合88 | 国产视频久久 | 在线观看亚洲精品视频 | 伊人网站在线 | 国产成人jvid在线播放 | 天天拍天天草 | 日韩欧美精品在线 | 国产91黄色| 久久久久亚洲精品国产 | 欧美一区二区三区在线观看视频 | 日韩在线精品视频 | 国产剧情一区 | 国产乱码精品一区二区三区忘忧草 | 欧美在线一区二区三区 | 欧美激情综合网 | 亚洲一二三区精品 | а天堂中文最新一区二区三区 | 日本网站免费观看 | 欧美自拍日韩 | 欧洲视频一区二区 | 精品美女久久久 | 欧美日韩黄色一级片 | 91大神xh98xh系列全部 | 91久久久久久久久 | 久久精品国产一区二区电影 | 国产精品污www一区二区三区 | 成人精品一区 | 免费观看日韩精品 | 久久激情视频 | 91免费在线看 | 一区二区三区在线 | 久久99国产精品 | 国产精品久久国产精品 | 精品久久国产老人久久综合 |