[eluser]Unknown[/eluser]
Hi all,
Bug or Feature?
I'd like to insert a record to a table without any field and value specified.
(the meaning of that is to store a timestamp, so the table has an auto incremented id and a timestamp with the default value populated by mySQL)
I tried this, because the insert method need a second parameter for the array of field/value pairs:
$this->db->insert("mytablename",array());
Got this error:
---
You must use the "set" method to update an entry.
---
Following the logic of Active Record my statement need to generate something like this:
INSERT INTO mytablename() VALUES ()
...which is a valid SQL statement and creates a record with the default values in the fields (in my case an auto incremented ID and a timestamp)
The solution what I found is:
$this->db->insert("mytablename",array("ID"=>""));
which is in SQL this:
INSERT INTO mytablename (ID) VALUES ("")
...which is also valid (? - not throwing error), but does not make much sense to specify in the object the auto incremented field.
Any thoughts?
Cheers,
Tibor