How to pass an integer to a request in CakePHP?

Edit 1: it's not about LIMIT , it's about passing an integer. Another function that requires passing numbers is IN

Edit 2: Should I use PDO :: PARAM_INT?


When I do this:

$query .=  ' LIMIT ? , ? ';
$values [] =  $offset ;
$values [] = $rows ;

In this line:

$db->fetchAll ( $query ,   $values);

Instead of doing:

SELECT .......  LIMIT 0 ,  10;

He is trying to do:

SELECT .......  LIMIT '0' ,  '10';

Cause an error: Error code: 1064. You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to '' 0 ',' 10 ''


Note 1. I know that there is an option for limiting in the $ params array. .

Note 2. There is a question related to here.

Note 3. I tried: $values [] = intval($offset), $values [] = (int)$offsetand even whole number:$values [] = 10

0
1

Cake, PDO intval PDO::PARAM_INT - .

PDO , , ,

0

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


All Articles