magetno定义表别名的XML配置

etc/config.xml中的配置如下

<models>
            <jopenid>
                <class>Jopenid_Model</class> <!-- Location of all model class files -->
                <resourceModel>jopenid_mysql4</resourceModel> <!-- Location of resource model -->
            </jopenid>
            <jopenid_mysql4>
                <class>Jopenid_Model_Mysql4</class>
                <entities>
                    <test>
                        <table>customer_entity_varchar</table>  <!-- Actual table name in sql  -->
                    </test>
                     <customerentity>
                        <table>customer_entity</table>  <!-- Actual table name in sql  -->
                    </customerentity>
                     <uopenid>
                        <table>usr_openid</table>
                    </uopenid>

                </entities>
            </jopenid_mysql4>
        </models>
代码如下
 $useropenid = Mage::getModel('jopenid/useropenid');
public function _construct()
    {
        parent::_construct();
        $this->_init('jopenid/uopenid'); // this is location of the resource file.
    }
这样jopenid/useropenid模块对应的表usr_openid就可以确定了

posted @ 2015-06-20 10:31  szphper  阅读(120)  评论(0)    收藏  举报