DB Insert -- Insert Query Errors out but insert happens??? |
[eluser]drewbee[/eluser]
Hello All, Just wanted to let you know I am new, but I am going through a very strange thing happening here. Basically after posting the form, a database error is displayed. However, the insert successfully happens. Any ideas on this one? First Post (Successfully Inserts) Code: A Database Error Occurred I refresh the page (duplicate key entry, shows query used for insert) Code: A Database Error Occurred Obviously I understand the second error (because even though the first post shows an error, it succesfully inserts. I've been scratching my head on this one... Any advice would be greatly appreciated!! Controller » _user_create() Code: function _user_create() Controller » General Area of index() that called _user_create() Code: $this->validation->use_tokenizer();
[eluser]drewbee[/eluser]
Yeah... for error handling should a db error occur. It just hasn't been written yet. The effect is the same with or without the return though. To Add to the issue, if I Copy the query after the refresh and actually paste it into phpMyAdmin ... inserts with no problem. (after truncate of course). Did I some how manage to stumble upon a bug? I'm not convinced yet.
[eluser]srobet[/eluser]
what about your 'account_lastlogin' => 0, is it in INT or another type ?
[eluser]drewbee[/eluser]
It is of int(10); -- Database Structure Dump: Code: CREATE TABLE IF NOT EXISTS `accounts` (
[eluser]richthegeek[/eluser]
try using DB transactions - the active record class has simple few methods for doing this.
[eluser]drewbee[/eluser]
I dont understand? There is only 1 query, and thus 1 Transaction that takes place.
[eluser]srobet[/eluser]
I've try to create table using your structure. And execute the sql : Code: INSERT INTO `accounts` ( `email` , `first_name` , `middle_initial` , `last_name` , `username` , `password` , `created` , `modified` , `account_type` , `account_group` , `account_lastlogin` , `account_status` ) Everything works well! M...... let's we find the problem together
[eluser]drewbee[/eluser]
OOOPS. It looks like I was confusing something here: I mixed up DB::insert_string() with DB::insert(); The method I was using was DB::insert(); which actually runs the query, as apposed to insert_string which returns the query. It was basically trying to execute a query on a TRUE statement.... doh... been a long day... thanks for the assistance. Code: return $this->db->insert('accounts', $data); //works. |
Welcome Guest, Not a member yet? Register Sign In |