[英]How to get desire format in PHP
Suppose in text box the sting is given: 假设在文本框中给出了字符串:
SELECT NAME,EMPLOYEEID, DEPARTMENT FROM EMPLOYEES E , DEPARTEMENT D WHERE E.DEPTID=D=DEPTID AND E.EMPLOYEEID='10';
output wants this format re-arranged accordingly 输出希望此格式相应地重新安排
SELECT
NAME,
EMPLOYEEID,
DEPARTMENT,
FROM
EMPLOYEES E,
DEPARTMENT D
WHERE
E.DEPTID=D=DEPTID
AND E.EMPLOYEEID='10';
A quick search for "php format sql string" online comes up with some relevant results: 在线快速搜索“ php格式的sql字符串”会得到一些相关结果:
SqlFormatter SqlFormatter
If you're using Composer: 如果您使用的是Composer:
require: {
"jdorn/sql-formatter": "dev-master"
}
Then you use it as follows: 然后按如下方式使用它:
$sql = "<query goes here>";
echo SqlFormatter::format($sql);
Similar question here on StackOverflow 类似的问题在这里StackOverflow
The (current) highest rated answer suggests using Regular Expressions or SED/AWK to solve the problem. (当前)最高评分的答案建议使用正则表达式或SED / AWK解决该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.