您的位置:首页 > 数据库

Magento中打印SQL语句来调试

2016-05-13 18:10 417 查看
有时为了调试magento商城系统,需要获取当前的查询sql语句

$collection->getSelectSql(true)来调试sql

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

1
$collection=Mage::getResourceModel(
'reports/product_collection'
);
2
$collection->printlogquery(
true
);
得到的SQL语句

SELECT
`e`.*
FROM
`catalog_product_entity`

AS
`e`
http://blog.sina.com.cn/s/blog_96ae64bd0100ycg7.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: