使用colleciton->getSelectSql()输出运行的SQL语句
$collection = Mage::getModel('catalog/category')->getCollection();  
echo $collection->getSelectSql(true);  
$collection->getSelectSql()->__toString();

magento获取SQL语句的另外一种方法是设置打印SQL为true
$collection=Mage::getResourceModel('reports/product_collection');  
$collection->printlogquery(true); 

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐