Can someone tell me how to make a connection in magento
Here is the problem:
<?
$collection= Mage::getModel('faq/faq')->getCollection();
$collection->getSelect()->join(array('faqcat' => $this->getTable('faqcat/faqcat')), 'faqcat.faqcat_id=faq.faqcat_id' , array('faqcat.*'));
?>
I am trying to make a connection to the faqcat table, where I use the faqcat_id key.
futher I want faqcat.name + faq.faq_id to be selected because these are the values that I want to use in colums.
<?
protected function _prepareColumns()
{
$this->addColumn('faq_id', array(
'header' => Mage::helper('faq')->__('ID'),
'align' =>'right',
'width' => '50px',
'index' => 'faq_id',
));
$this->addColumn('name', array(
'header' => Mage::helper('faqcat')->__('Titel'),
'align' =>'left',
'index' => 'name',
));
}
?>
after trying 1000 combinations I don’t know what to do next ... who wants to help me
this is the full function:
<?
protected function _prepareCollection()
{
$collection= Mage::getModel('faq/faq')->getCollection();
$id = Mage::getModel('customer/session')->getCustomer()->getId();
$this->setCollection($collection);
return parent::_prepareCollection();
}
?>
to be clear, this is the sql I want to have, but then the magenta path
<?
SELECT faq.faq_id as id, faqcat_name as name
FROM faq
JOIN faqcat
USING ('faqcat_id')
?>
Paulo source
share