• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Query bindings in CI 3

#1
Hi!

I just updated from CI 2.x to CI 3.1.11.
Everything works fine except :

Now the query function checks that the number of supplied parameters matches the number of bind marker present in the sql query.

This change was not mentioned in the upgrade guide.

How to get rid of that check. 

I have some conditional queries that don't work anymore due to that parameter check.

ex : SELECT ?, ? FROM table; 
should work even if too many parameters supplied 
$param = ['a','b','c']; => 'c' is just discarded.

THANK YOU!
Reply

#2
(12-05-2019, 09:04 AM)Danny Wrote: Hi!

I just updated from CI 2.x to CI 3.1.11.
Everything works fine except :

Now the query function checks that the number of supplied parameters matches the number of bind marker present in the sql query.

This change was not mentioned in the upgrade guide.

How to get rid of that check. 

I have some conditional queries that don't work anymore due to that parameter check.

ex : SELECT ?, ? FROM table; 
should work even if too many parameters supplied 
$param = ['a','b','c']; => 'c' is just discarded.

THANK YOU!
Prepared statements are usually not used for column names.
Also, if you have 3 elements in $param, you should have 3 question marks in your query.

An example of a prepared statement:
Code:
"INSERT INTO users (firstname, lastname, email) VALUES (?, ?, ?)"
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.