时间:2021-07-01 10:21:17 帮助过:17人阅读
本文实例讲述了PHP实现SQL语句格式化功能的方法。分享给大家供大家参考,具体如下:
一、问题:
要求使用php实现针对sql语句的格式化功能
二、解决方法:
具体代码如下:
<?php include('SqlFormatter.php'); $sql="SELECT DATE_FORMAT(b.t_create, '%Y-%c-%d') dateID, b.title memo FROM (SELECT id FROM orc_scheme_detail d WHERE d.business=208 AND d.type IN (29,30,31,321,33,34,3542,361,327,38,39,40,41,42,431,4422,415,4546,47,48,'a', 29,30,31,321,33,34,3542,361,327,38,39,40,41,42,431,4422,415,4546,47,48,'a') AND d.title IS NOT NULL AND t_create >= DATE_FORMAT((DATE_SUB(NOW(),INTERVAL 1 DAY)),'%Y-%c-%d') AND t_create < DATE_FORMAT(NOW(), '%Y-%c-%d') ORDER BY d.id LIMIT 2,10) a, orc_scheme_detail b WHERE a.id = b.id"; echo SqlFormatter::format($sql); ?>
运行结果如下图所示:
相关推荐:
如何使用vue.js实现价格格式化(代码附上)
Vue过滤器格式化方法详解
Python格式化输出%s和%d
以上就是PHP实现SQL语句格式化功能的详细内容,更多请关注Gxl网其它相关文章!