我正在使用一个使用
$pattern = "LIMIT[^\w]{1,}([0-9]{1,})([\,]{0,})([0-9]{0,})";
$replacement = "";
eregi($pattern, $query, $regs);
$query = eregi_replace($pattern, $replacement, $query);
if($regs[2])
$query = str_ireplace("SELECT ", "SELECT TOP ".$regs[3]." ", $query);
else
{
if($regs[1])
$query = str_ireplace("SELECT ", "SELECT TOP ".$regs[1]." ", $query);
}
我将部分代码更改为
$pattern = "/LIMIT[^\w]{1,}([0-9]{1,})([\,]{0,})([0-9]{0,})/i";
$replacement = "";
preg_match($pattern, $query, $regs);
但现在我收到错误消息说“未定义的偏移量:2”和“未定义的偏移量:1”
我认为从eregi 转移到preg_match 应该很容易......