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
发布于 2012-11-14 03:36:33
假设你是一个标准集合的子类,它应该是:
$collection->getSelect()->join($this->getTable('maps/[table_entity]'), 'main_table.reseller_id= reseller_merch.reseller_id');这是假设你的实体是这样命名的。
https://stackoverflow.com/questions/13362893
复制相似问题