开发者

Perform Joins In Magento

开发者 https://www.devze.com 2023-03-16 04:27 出处:网络
I want to display matching data based on\'customer_id\' by joining \'customer_en开发者_如何学JAVAtity_varchar\' and \'salesrule_coupon_usage\'.How can i perform joins in magento.Do i have to run raw s

I want to display matching data based on'customer_id' by joining 'customer_en开发者_如何学JAVAtity_varchar' and 'salesrule_coupon_usage'.How can i perform joins in magento.Do i have to run raw sql queries to perform joins?


This is not the proper way, but might have mileage for you in this instance:

$yourquery="SELECT * FROM customer_entity_varchar AS cev INNER JOIN salesrule_coupon_usage AS scu ON cev.customer_id=scu.customer_id WHERE blah blah"; 

$macguffin=Mage::getSingleton('core/resource')->getConnection('core_write');

$macguffin->query($yourquery);

$yourqueryresult=$macguffin->fetch(PDO::FETCH_ASSOC);

For the proper way, have a look at 'filtering database collections' in Alan Storm's guide:

http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-8-varien-data-collections/magento-for-dev-part-1-introduction-to-magento

0

精彩评论

暂无评论...
验证码 换一张
取 消