Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

query builder (insert) suggestion

$
0
0
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

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>