如果我删除这行var_dump代码,我的模块就会崩溃。为什么会这样呢。我的连接有什么问题吗?
protected function _prepareCollection() {
$collection = mage::getModel('faq/faq')->getCollection();
$collection->getSelect()->joinLeft(array('s'=>'gagan_faq_creation'),
'main_table.faq_id = s.faq_id');
var_dump($collection->getData());
$this->setCollection($collection);
parent::_prepareCollection();
}我得到了这个错误
QLSTATE[23000]: Integrity constraint violation: 1052 Column 'faq_id' in order clause is ambiguous
#0 C:\wamp\www\www.ubt.com\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 C:\wamp\www\www.ubt.com\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 C:\wamp\www\www.ubt.com\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 C:\wamp\www\www.ubt.com\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `main_ta...', Array)
#4 C:\wamp\www\www.ubt.com\lib\Varien\Db\Adapter\Pdo\Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `main_ta...', Array)发布于 2013-03-24 01:49:17
您正在从两个表(main_table和gagan_faq_creation)中选择faq_id,这就是为什么它会给出MySQL错误,因此需要为gagan_faq_creation.faq_id添加联盟。
https://stackoverflow.com/questions/15590002
复制相似问题