Escape from CakePHP Page Status

Request List:

$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 appends a single quote to original_price 77, so it causes problems with number matching.

Cakephp request output:

............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_priceis a field varchar. 77in quotation marks that cannot match the mysql field.

Any help would be appreciated.

+4
source share
1 answer

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, key => valuejust use value. But usually it doesn’t matter if the number is in quotation marks, even with varchar.

+1
source

Source: https://habr.com/ru/post/1686795/


All Articles