0

我正在尝试做这样的事情:

$url = 'test/';
$url = rtrim($url, "'");
$url = $db->quote($url);
$sql = "SELECT * FROM mytable WHERE url = '{$url}' OR url = '{$url}/'";

但是这个返回: SELECT * FROM mytable WHERE url = ''test/'' OR url = ''test/'/'

我基本上想要 Zend 的 mysql_real_escape_string 等价物。

4

1 回答 1

1

试试like喜欢

$sql = "SELECT * FROM mytable WHERE url LIKE '%{$url}/%'";

或者你也可以试试

$url = 'test/';
$sql = "SELECT * FROM mytable WHERE url LIKE '%{$url}%'";
于 2013-11-07T10:52:36.833 回答