Welcome Guest, Not a member yet? Register   Sign In
query builder (insert) suggestion
#1

Hello,
Unless I am using this wrong (first CI site build), this produces a db error, asking to use the set() method:


PHP Code:
$dummy_data = array();
$this->db->insert('mytable',$dummy_data); 


Where this does not produce an error:

PHP Code:
$this->db->query("INSERT INTO 'mytable' () VALUES()"); 

You may ask.. "Why insert into a table with no data?"...

I have a database that is one field, which is an auto-incrementing ID field. I do a blank insert, then grab the new ID with:

PHP Code:
$this->db->insert_id(); 

Sincerely,
Donovan
Reply




Theme © iAndrew 2016 - Forum software by © MyBB