CodeIgniter Forums
query binding is not working correctly - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: query binding is not working correctly (/showthread.php?tid=19634)



query binding is not working correctly - El Forum - 06-13-2009

[eluser]jstuardo[/eluser]
Hello,

I have problems with query bindings. First of all, I have this code to insert data:

Code:
$sql = 'insert into inscrito (fecha_inscripcion, eve_id, rut, dv, nombres, apellidos, edad, email, telefono)
        values (now(), ?, ?, ?, ?, ?, ?, ?, ?)';
$this->db->query($sql, array($evento, $rut, $dv, $nombres, $apellidos, $edad, $telefono));

When I run the code, this is the query which was actually executed:

Code:
insert into inscrito (fecha_inscripcion, eve_id, rut, dv, nombres, apellidos, edad, email, telefono) values (now(), '1', '11727935', '9', 'Jaime', 'Stuardo', '38', '2493766',

Why the "comma" is appended to the end instead of the "parenthesis"?

Is there another way to insert a datetime into a database field? I think the problem occurs because of now() and $this->db->insert does not seem to work when I have to pass NOW() as the parameter.

Thanks
Jaime


query binding is not working correctly - El Forum - 06-13-2009

[eluser]TheFuzzy0ne[/eluser]
Because you're query is expecting another parameter (You have 8 ?s and only 7 bindings).