10-28-2018, 05:28 PM
This query will not work if I try to bind the limit and the offset. I works fine if I type in 'LIMIT 20 OFFSET 0'.
This line binds the variables.
I had to go into the query method of the userspice DB class and add a line...
Now it works fine. I cannot figure out why it won't work otherwise. I am using uniform server with php 7.1.1 and MySQL 5.6.35. I am new to PDO. I never had issues like this with mysqli. Is this something I am doing wrong?
Code:
$q = 'SELECT *, DATE_FORMAT(l.date, "%m/%d/%Y") as `date`
FROM db_listings l
WHERE l.omit=0
AND l.closed=0
ORDER BY l.id DESC
LIMIT ? OFFSET ?;';
This line binds the variables.
Code:
$db->query($q,array($arr['lim'],$arr['off']));
I had to go into the query method of the userspice DB class and add a line...
Code:
public function query($sql, $params = array()){
$this->_pdo->setAttribute( PDO::ATTR_EMULATE_PREPARES, false ); /* ADDED LINE */
Now it works fine. I cannot figure out why it won't work otherwise. I am using uniform server with php 7.1.1 and MySQL 5.6.35. I am new to PDO. I never had issues like this with mysqli. Is this something I am doing wrong?