<?php
$str = 'indistinct';
if (preg_match('/[^in]distinct/',$str)) {
echo "OK";
} else {
echo "Error";
}
?>
给分给分
$str = 'indistinct';
if (preg_match('/[^in]distinct/',$str)) {
echo "OK";
} else {
echo "Error";
}
?>
给分给分
$sSQL="select count(".$reg[0].") ".strstr($query,"from");结果碰上"select * from t1 where f1 in (select distinct f1 from t2)",又不行了现在eregi($patten,$sSQL,$reg),想求$patten的写法
if (preg_match('/(^in)distinct/',$str)) {
echo "Error";
} else {
echo "OK";
}
$sSQL="select count(".$reg[0].") ".strstr($sSQL,"from");我想让$reg[0]的值为"distinct 字段名"……谢谢
首先mysql并不支持这个写法:"select * from t1 where f1 in (select distinct f1 from t2)",所以也无通用可言了。
其次,在你的表达式中并未出现(),所以在eregi(" distinct +[[:alnum:]]+",$sSQL,$reg)后,$reg是无效的。
取出select的后的字段列表,只需排除distinct即可
没有(),也能用呀,在只匹配一个东西的情况下
{
$reg[2]="0";
}
$sSQL="select count(".$reg[2].") ".strstr($sSQL,"from");应该是可以了,谢谢大家