Welcome Guest, Not a member yet? Register   Sign In
Query bindings in CI 3
#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


Messages In This Thread
Query bindings in CI 3 - by Danny - 12-05-2019, 09:04 AM
RE: Query bindings in CI 3 - by muuucho - 12-06-2019, 04:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB