CodeIgniter Forums
QueryBuild appends undeclared column names, need to reset qb_set - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: QueryBuild appends undeclared column names, need to reset qb_set (/showthread.php?tid=66234)



QueryBuild appends undeclared column names, need to reset qb_set - 678238515702801 - 09-25-2016

Today I came across a strange phenomena with Query Builder.

Whenever I use $this->db->insert($array_to_insert), it appends two undeclared table names to the query causing it to fail.

I found the culprit when I used var_dump(db) and found the two inside the array qb_set:

["qb_set":protected]=> array(2) { ["`col_1`"]=> string(2) "''" ["`col_2`"]=> string(2) "''" }

How do you guys recommend resetting this array properly? I swear I do not use col_1 and col_2 nowhere near where I perform insertions.


RE: QueryBuild appends undeclared column names, need to reset qb_set - Paradinight - 09-25-2016

Make a var_dump to $array_to_insert.


RE: QueryBuild appends undeclared column names, need to reset qb_set - 678238515702801 - 09-25-2016

(09-25-2016, 01:58 AM)Paradinight Wrote: Make a var_dump to $array_to_insert.

I tried that and the two columns were not in the result.


RE: QueryBuild appends undeclared column names, need to reset qb_set - InsiteFX - 09-25-2016

Show your code for inserting the array.


RE: QueryBuild appends undeclared column names, need to reset qb_set - Wouter60 - 09-25-2016

You can't use $this->db->insert($array_to_insert) like that.
$this->db->insert() expects 2 parameters. The first one is the table name, the second one is an array with field names and values for that table.