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
精彩评论