大家好,我有一个在 cakephp 中开发的网站,我在 pdo 中有一个查询,我想在其中插入一个限制值。我尝试过这种模式:
$max_result = 10;
$search = "test";
$product_alias = $this->ProductAlias->query(
'SELECT DISTINCT *
FROM product_aliases
WHERE product_aliases.alias
LIKE :search LIMIT :limit_search'
,array('search' => '%'.$search.'%','limit_search' => intval(trim($max_result)))
);
我也试过:
...
WHERE product_aliases.alias
LIKE :search
LIMIT :limit_search'
,array('search' => '%'.$search.'%','limit_search' => intval($max_result)));
和
...
WHERE product_aliases.alias
LIKE :search
LIMIT :limit_search'
,array('search' => '%'.$search.'%','limit_search' => $max_result));
但总是给我这个错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10' at line 1
我已经看到有绑定,但我不知道如何应用于这种情况。有什么解决办法吗?