簡體   English   中英

Magento中的加入問題

[英]Problems joining in Magento

Table 1
--------------
|reseller_id |
|1           |
|2           |
|3           |
|4           |
--------------

Table 2
-------------------------------
|reseller_id | merchandise_id |
|1           | 1              |
|1           | 3              |
|2           | 1              |
|2           | 4              |
|3           | 2              |
-------------------------------

select * from reseller_maps inner join reseller_merch on reseller_maps.reseller_id = reseller_merch.reseller_id;

給我我在數據庫方面尋找的東西。 但是,我得到了

 Call to undefined method Namespace_Class_Model_Mysql4_Reseller_Collection::joinTable() 

嘗試在Magento中執行$ collection-> joinTable()時。

我試過使用getSelect和join():

        $collection = Mage::getModel('maps/reseller');
        $collection->getSelect()
            ->join( array( 'reseller_merch'=>$this->getTable('reseller_merch')), 'reseller_maps.reseller_id= reseller_merch.reseller_id', array('reseller_merch.*'));

並得到:

 SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''

據我所知,這直接來自Wiki上的示例代碼: http : //www.magentocommerce.com/wiki/1_-_installation_and_configuration/using_collections_in_magento

假設您要對標准集合進行子類化,則應為:

$collection->getSelect()->join($this->getTable('maps/[table_entity]'), 'main_table.reseller_id= reseller_merch.reseller_id');

假設您的實體是以這種方式命名的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM