在magento 1.8.0.0版本中运行mysql复杂查询

时间:2013-12-09 09:33:16

标签: mysql magento

如何在magento 1.8.0.0中的mysql查询下运行

select
    m.*,
    group_concat(c.store_id)
from
    news m
    join news_store c on find_in_set(c.news_id, m.news_id)
group by
    m.news_id

1 个答案:

答案 0 :(得分:1)

您可以执行以下操作:

$read = Mage::getSingleton('core/resource')->getConnection('core_read');

// now $write is an instance of Zend_Db_Adapter_Abstract
$read ->query("select m.*,
    group_concat(c.store_id)
    from
    news m
    join news_store c on find_in_set(c.news_id, m.news_id)
    group by
    m.news_id");

How to do custom query in magento?