Welcome Guest, Not a member yet? Register   Sign In
Real life example of using Query Bindings needed
#2

The binding will take care of adding quotes as needed. However, I have run into problems with using it for a list of elements for a WHERE IN statement. For your first example, I believe something like this would work out:

Code:
$ids = [3, 6];
$sql = "SELECT * FROM some_table WHERE id IN ('". implode(',', $ids) ."') AND status = ? AND author = ?";
$this->db->query($sql, ['live', 'Rick']);

From the error on your second query, it sounds like you have quotes around the first ?, also, which isn't needed and would likely cause errors.
Reply


Messages In This Thread
RE: Real life example of using Query Bindings needed - by kilishan - 02-03-2016, 02:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB