开发者

Can't configure model resource on config.xml

开发者 https://www.devze.com 2023-03-17 22:53 出处:网络
I get a fatal error when trying to instantiate a Model in Magento and call method load(). I\'ve just config the resource model and maybe my config.xml is not well-formed.

I get a fatal error when trying to instantiate a Model in Magento and call method load(). I've just config the resource model and maybe my config.xml is not well-formed.

<config>
<frontend>
<routers>
    <weblog>
        <use>standard</use>
        <args>
            <module>Mypack_Weblog</module>
            <frontName>weblog开发者_Python百科</frontName>
        </args>
    </weblog>
</routers>
</frontend>   
<global>
<models>
    <weblog>
        <class>Mypack_Weblog_Model</class>
        <resourceModel>weblog_mysql4</resourceModel>
        <weblog_mysql4>
            <class>Mypack_Weblog_Model_Mysql4</class>              
        </weblog_mysql4>
    </weblog>   
</models>
</global>
</config>

I'm a beginner and spent many hours on it : please, help !


The resource model doesn't go inside the other model.

<global>
    <models>
        <weblog>
            <class>Mypack_Weblog_Model</class>
            <resourceModel>weblog_mysql4</resourceModel>
        </weblog>   

        <weblog_mysql4>
            <class>Mypack_Weblog_Model_Mysql4</class>              
        </weblog_mysql4>
    </models>
</global>


I'm working through the same tutorial (http://alanstorm.com/magento_models_orm) and have figured out the way that config.xml should look at the point in the tutorial where you seem to be:

<config>    
<modules>
    <Alanstormdotcom_Weblog>
        <version>0.1.0</version>
    </Alanstormdotcom_Weblog>
</modules>
<frontend>
    <routers>
        <weblog>
            <use>standard</use>
            <args>
                <module>Alanstormdotcom_Weblog</module>
                <frontName>weblog</frontName>
            </args>
        </weblog>
    </routers>
</frontend>
<global>
    <!-- ... -->
    <models>
        <weblog>
            <class>Alanstormdotcom_Weblog_Model</class>
            <!-- 
            need to create our own resource, can't just
            use core_mysql4
            -->
            <resourceModel>weblog_mysql4</resourceModel>
        </weblog>
        <weblog_mysql4>
            <class>Alanstormdotcom_Weblog_Model_Mysql4</class>
        </weblog_mysql4>
    </models>
    <!-- ... -->
</global>

Excuse the less-than-pretty indentation :).

0

精彩评论

暂无评论...
验证码 换一张
取 消