我想先找到select ...下面的代码替换了sql查询中的所有select..from,我只需要第一个select..from
preg_replace('#select(.*?)from#is', "select count($expr) as counted from", $sql);发布于 2009-09-11 13:16:38
对于preg_replace(),还有第四个可选参数'limit‘,它定义了替换的数量,缺省为-1 (表示没有限制)
preg_replace('#select(.*?)from#is', "select count($expr) as counted from", $sql, 1);https://stackoverflow.com/questions/1410683
复制相似问题