ckliang 2013-07-18 15:00:03 24194次浏览 6条回复 0 0 0

怎么输出SQL语句?像thinkphp框 架一样有个getLastSql()方法,YII有类似的方法吗?

  • 回复于 2013-08-01 13:21 举报

    /protected/config/main.php的'componets'数组里

    'log'=>array(
    'class'=>'CLogRouter',
    'routes'=>array(
    	array(
    		'class'=>'CWebLogRoute',
    		//'levels'=>'profile',
    		//'categories'=>'system.*',
    		//'categories'=>'system.db.CDbCommand,system.caching.*',
    ),),
    
  • 回复于 2013-08-01 13:21 举报

    额 少了个结束的括号

  • 回复于 2013-08-01 17:01 举报
    INSERT INTO `tbl_post` (`title`, `content`, `tags`,
    `status`, `create_time`, `update_time`, `author_id`) VALUES (:yp0, :yp1,
    :yp2, :yp3, :yp4, :yp5, :yp6)
    

    怎么让VALUES()里面的:yp0;yp1...等显示呢?

    1 条回复
    回复于 2016-10-13 15:22 回复

    你是怎么输出sql语句的?

  • 回复于 2013-08-01 18:04 举报

    看不太懂哦,不过还是谢谢你,我怎么在日志里面看到一条完整的SQL语句呢比如:

    INSERT INTO `tbl_post` (`title`, `content`, `tags`,
    `status`, `create_time`, `update_time`, `author_id`) VALUES (“新闻”, “新闻内容”,
    “标签”, 1, 134578800 ,134578845, 3)而不是:
    INSERT INTO `tbl_post` (`title`, `content`, `tags`,
    `status`, `create_time`, `update_time`, `author_id`) VALUES (:yp0, :yp1,
    :yp2, :yp3, :yp4, :yp5, :yp6)**
    
  • 回复于 2013-08-02 10:29 举报
    SELECT * FROM `tbl_user` `t` WHERE `t`.`username`=:yp0 LIMIT 1. Bound with :yp0='Johnny'
    

    这个效果虽然跟你要的不完全一样,但能满足你的需求,你只要装个插件就可以了。
    http://www.yiiframework.com/extension/dbprofiler/

您需要登录后才可以回复。登录 | 立即注册