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

從 magento 模塊創建一個新表

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

問題描述

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

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>

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

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 在他的評論中指出的那樣,如果您尚未創建模塊,您將需要 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 模塊創建一個新表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
主站蜘蛛池模板: 久久99精品久久久久久青青日本 | 国产免费一区二区三区 | 欧美亚洲一区二区三区 | 天天操人人干 | 精品欧美在线观看 | 色婷婷国产精品 | 一级毛片在线播放 | www.887色视频免费 | 麻豆精品一区二区三区在线观看 | 日韩中文字幕在线观看 | 亚洲视频免费观看 | 国产九九九九 | 日韩国产专区 | 久久国内精品 | 亚洲 欧美 日韩 在线 | 久草久草久草 | 国产日韩欧美二区 | 伊人一二三| 国产免费一区二区 | 9191av| 欧美爱爱视频 | 视频在线一区二区 | 欧美一区二区免费 | 亚洲国产精品久久久 | 五月天婷婷久久 | 久久久精 | 国产成人精品网站 | 中文字幕91 | 日本精a在线观看 | 欧美精品久久久久 | 欧美福利一区 | 人人鲁人人莫人人爱精品 | 国产精品久久视频 | 2019天天干天天操 | 欧美一级二级在线观看 | 欧美日韩综合一区 | 日本成人福利视频 | 久久久久国产一区二区三区 | 成人一区二区三区在线观看 | 欧美一级二级视频 | 亚洲最大成人综合 |