Hello!

How to send a request for sampling with the participation of LIMIT'a through PDO, using an array and without the participation of bind'a?

I try this:

$array_db = Array(0, 10); $sql = $db->prepare("select * from `table` limit ?, ?"); $sql->setFetchMode(PDO::FETCH_ASSOC); $sql->execute($array_db); $row = $sql->fetchAll(); 

As a result, it gives an error: SQLSTATE [42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the syntax for your right syntax to use the '' 0 ',' 10 '' at line 1

Thank!

  • This option, I tried. He did not help me to solve the problem. - N0ob
  • I'm not talking about the option, but about your bug, which is 8 years old (if not more). Here such crazy record $array_db = Array((int)0, (int)10); won't work either? - Visman
  • @Visman Thank you! - Nicolas Chabanovsky

1 answer 1

Do not take idle answers. This causes great harm to both the site and those who come to this question through a search.

About the fact that it is not necessary to write meaningless answers, I will not say - it is still useless.

The correct answer to the question, "How to send a request for a sample with the participation of LIMIT'a without the participation of bind'a?" will disable emulation mode :

 $db->setAttribute( PDO::ATTR_EMULATE_PREPARES, false ); 
  • Where have you been before !? I can not delete the answer without removing the "correct answer". - Visman