【问题标题】:Magento joining 2 tablesMagento 加入 2 张桌子
【发布时间】:2014-03-31 14:38:48
【问题描述】:

我想在 magento 中加入 admin 表和另一个配置文件表,我该怎么做?

我想加入$userModel = Mage::getModel('admin/user'); 表和

$vendorModel = Mage::getModel('vendorprofile/vendor');

【问题讨论】:

  • 两个集合之间的关系关键词是什么???

标签: php sql magento


【解决方案1】:

Riaz.try 下面的代码 ---

           $collection = Mage::getModel('admin/user')->getCollection();
    /* start inner join .vendorprofiletable is the 
Mage::getModel('vendorprofile/vendor') module table */
          $collection->getSelect()->join( array('vendorprofile'=> 'vendorprofiletable'), 
        'vendorprofile.vendor_id = main_table.entity_id', array('*'));

这里假设 vendorprofile.vendor_id = main_table.entity_id 是两个表之间的关系。

如果你想得到join的查询,那么echo $collection->getSelect();

希望对你有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多