1

您好我正在尝试使用数据库创建简单的模块,但我找不到我的错误,我不知道如何找到它(以及调试方法)我的文件结构是:
MyNameSpace
-SkipCart
--controllers
---IndexController。 php
--etc
---config.xml
--Helper
---Data.php
--Model
---Mysql4
----SkipCart
------Collection.php
----SkipCart.php
--- SkipCart.php
--sql
---SkipCart_setup
----mysql4-install-0.0.1.php

文件中的代码是:

索引控制器.php

class MyNameSpace_SkipCart_IndexController extends Mage_Adminhtml_Controller_Action {
     public function indexAction()
    {
        $this->loadLayout();

        //create a text block with the name of "example-block"
        $block = $this->getLayout()
        ->createBlock('core/text', 'example-block')
        ->setText('<h1>This is a text block</h1>');

        $this->_addContent($block);
  //add menu active
        $this->_setActiveMenu('tutorial_menu/first_page');
       // $this->_setActiveMenu('system/another_menu_from_us');
        $this->renderLayout();


    }


}

配置文件

<config>

    <admin>
        <routers>
            <test>
                <use>admin</use>
                <args>
                    <module>MyNameSpace_SkipCart</module>
                    <frontName>skipcart</frontName>
                </args>
            </test>
        </routers>
    </admin>
     <adminhtml>
        <menu>
            <tutorial_menu translate="title" module="skipcart">
                <title>Skip Cart</title> 
                <sort_order>9999</sort_order>
                <children>
                    <first_page module="skipcart">
                        <title>Our First Page</title> 
                        <action>skipcart/index/index</action>
                    </first_page>
                </children>
            </tutorial_menu>
        </menu> 
         <system>
                <children>
                    <another_menu_from_us>
                        <title>Here Too!</title> 
                        <action>skipcart/index/index</action>
                    </another_menu_from_us>
                </children>
            </system>
    </adminhtml>
    <global>
        <helpers>
            <skipcart>
                <class>MyNameSpace_SkipCart_Helper</class>
            </skipcart>
        </helpers>
    </global>
    <global>
        <blocks>
            <checkout>
                <rewrite>
                    <cart>MyNameSpace_SkipCart_Block_Cart</cart>
                </rewrite>
            </checkout>
        </blocks>
    </global>



     <global>
        <models>
            <skipcart>
                <class>MyNameSpace_SkipCart_Model</class>
                <resourceModel>mynamespace_skipcart_mysql4</resourceModel>
            </skipcart>
            <skipcart_mysql4>
                <class>MyNameSpace_SkipCart_Model_Mysql4</class>
                <entities>
                    <skipcart>
                        <table>skipcart</table>
                    </skipcart>
                </entities>
            </skipcart_mysql4>
        </models>
        <resources>
            <skipcart_setup>
                <setup>
                    <module>MyNameSpace_SkipCart</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </skipcart_setup>
            <skipcart_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </skipcart_write>
            <skipcart_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </skipcart_read>
        </resources>
        <blocks>
            <skipcart>
                <class>MyNameSpace_SkipCart_Block</class>
            </skipcart>
        </blocks>
        <helpers>
            <skipcart>
                <class>MyNameSpace_SkipCart_Helper</class>
            </skipcart>
        </helpers>
    </global>
</config>

数据.php

class MyNameSpace_SkipCart_Helper_Data extends Mage_Core_Helper_Abstract
{
}

--Model
---Mysql4
---SkipCart.php

class MyNameSpace_SkipCart_Model_SkipCart extends Mage_Core_Model_Abstract {

    public function _construct(){
        parent::_construct();
        $this->_init('skipcart/skipcart');
    }
}

--Model
---Mysql4
----SkipCart
-----Collection.php

 class MyNameSpace_SkipCart_Model_Mysql4_SkipCart_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
    public function _construct()
    {

        $this->_init('SkipCart/skipcart');
    }
}

--Model
---Mysql4
----SkipCart
----SkipCart.php

    class MyNameSpace_SkipCart_Model_Mysql4_SkipCart extends Mage_Core_Model_Mysql4_Abstract
    {
        public function _construct()
        {   
            $this->_init('skipcart/skipcart', 'skipcart_id');
        }
    }

--sql
---SkipCart_setup
----mysql4-install-0.0.1.php

    <?php

    $installer = $this;

    $installer->startSetup();

    $installer->run("

    -- DROP TABLE IF EXISTS {$this->getTable('skipcart')};
    CREATE TABLE {$this->getTable('skipcart')} (
      `skipcart_id` int(11) unsigned NOT NULL auto_increment,
      `status` smallint(6) NOT NULL default '0',
      PRIMARY KEY (`skipcart_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

        ");

    $installer->endSetup();

任何人都可以帮助我找到问题,并且可以解释我如何单独查找和调试错误吗?

4

0 回答 0