<?php
$Str="select a.*,b.* from aaa a left join bbb b on a.id=b.id where a.id=33 group by a.id order by b.id";
echo preg_replace("/select (.+?) from (.+?) where (.+?) /i","$1<br />$2<br />$3<br />",$Str);
?>没搞清你要干什么~~
乱写个先……
$Str="select a.*,b.* from aaa a left join bbb b on a.id=b.id where a.id=33 group by a.id order by b.id";
echo preg_replace("/select (.+?) from (.+?) where (.+?) /i","$1<br />$2<br />$3<br />",$Str);
?>没搞清你要干什么~~
乱写个先……
解决方案 »
- 请教高手 关于Smarty的问题!!!
- unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'
- 如何统计访问者的行为?高手进
- PHP如何连接mssql,需要配置什么?做过的请指导一下吧
- 散分-怎么知道离升星还有几分啊?
- 我得论坛有漏洞,可是我不知道在什么地方,请各位帮忙找找,PHP+SQL Server,谢谢
- 幫幫忙。PHP 如何連接 SQLSERVER
- php里的PHP.exe具体是干什么用的
- 如何使用本地函数?就像调用javascript函数一样?在线等待!!
- PHP远程数据库部署。集群部署。
- 如何检测数据是否正确
- 求救啊,做不出来就被开除了!
select * from aaa where x="xasdfas select saflsafj from asfsaf where safasf";
select .... from .....
select .... from .... order by ...
select .... from .... group by ... order by ...
select .... from .... where ....
select .... from .... where .... order by ...
select .... from .... where .... group by ... order by ...
主要的就是这些了吧,就是order by ... 部分不要 group by ...部分不要 然后有where的,join的 都包含到第二部分里边 select的部分算第一部分
$Str="select a.*,b.* from aaa a left join bbb b on a.id=b.id where x=\"xasdfas select saflsafj from asfsaf where x=\"xasdfas select saflsafj from asfsaf where x=\"xasdfas select saflsafj from asfsaf where safasf\"\" safasf\" a.id=33 group by a.id order by b.id ";
print preg_replace("/select(.+?)from(.+?)where(.*?)(order|group)/","Se: $1<br />Fro: $2<br /> Whe $3 <p />",$Str);
?>结果:
---------------
Se: a.*,b.*
Fro: aaa a left join bbb b on a.id=b.id
Whe x="xasdfas select saflsafj from asfsaf where x="xasdfas select saflsafj from asfsaf where x="xasdfas select saflsafj from asfsaf where safasf"" safasf" a.id=33 by b.id group by a.id
---------------
可包含无限子查询
换成
'order by b.id group by a.id'
'group by a.id order by b.id'
都没问题但~~
哪位高手给看看,我搞了半天'by b.id group by a.id'也没去掉.