-2

我有一个包含 sql 语句的字符串,如下所示:

$sql = "SELECT nic_number, client_title, client_lastname FROM customer ORDER BY id_client LIMIT 0, 1";

我想从中删除LIMIT 0, 1,以便它变成

SELECT nic_number, client_title, client_lastname FROM customer ORDER BY id_client

多谢你们。

4

3 回答 3

1

使用str_replace

echo str_replace("LIMIT 0, 1", "", $sql);
于 2013-02-25T13:07:26.913 回答
1
$sql = 'SELECT nic_number, client_title, client_lastname FROM customer ORDER BY id_client LIMIT 0, 1';
echo $sql = preg_replace('/LIMIT \d+, \d+/', '', $sql);
于 2013-02-25T13:10:07.793 回答
0

假设内容始终相同:

$sql = str_replace('LIMIT 0, 1', '', $sql);
于 2013-02-25T13:07:31.057 回答