[英]Escape from CakePHP Paginate condition
Paginate query: 分页查询:
$this->paginate = array(
'conditions' => array(
// 'Product.soft_delete NOT' => 'on',
// 'Product.product_status NOT' => 'inactive',
// $conditions
'Product.original_price <=' => 77
),
'recursive' => 2,
// 'order' => $sort_by,
'paramType' => 'querystring',
'limit' => '25',
'maxLimit' => 100,
);
$records = $this->paginate('Product');
CakePHP adding single quote to original_price 77
so it is creating problems in number comparison. CakePHP在original_price
77
添加了单引号,因此它在数字比较中产生了问题。
Cakephp query output: Cakephp查询输出:
............LEFT JOIN `admin_mytab`.`seller_categories` AS `Seller_3` ON (`Product`.`seller_3` = `Seller_3`.`id`) WHERE `Product`.`original_price` <= '77' LIMIT 25
MySQL original_price
is varchar
field. MySQL
original_price
是varchar
字段。 77
in quotes unable to compare with mysql field. 用引号
77
无法与mysql字段进行比较。
Any help would be appreciated. 任何帮助,将不胜感激。
Try writing it like this: 尝试这样写:
$this->paginate = array(
'conditions' => array(
'Product.original_price <= 77'
),
'recursive' => 2,
'paramType' => 'querystring',
'limit' => '25',
'maxLimit' => 100,
);
$records = $this->paginate('Product');
Instead of key => value
just use value
. 除了使用
key => value
可以使用value
。 But usually it doesn't matter if number is enclosed with quotes, even with varchar
. 但是通常,数字是否用引号引起来,即使使用
varchar
也不重要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.