Welcome Guest, Not a member yet? Register   Sign In
Can't write data into database
#4

[eluser]cideveloper[/eluser]
I just looked at your code again and am wondering what you are attempting to do here. Please explain what this code is supposed to do, because what I can figure out does not make sense.

if $this->input->post('username') is not in the database it will return nothing. Then you can not insert that into table address most likely because you have a not null constraint on the field USERS_USR_ID.

if $this->input->post('username') is in the database you will have a bigger problem. You will be creating a new user in the users table but the USERS_USR_ID in the address table will be from the previously found user.


I think what you want to do is this:

1) insert user table
2) get last inserted id from user table ($this->db->insert_id())
3) insert into address table with USERS_USR_ID coming from (2)
4) get last inserted id from address table ($this->db->insert_id())
5) insert into client table with Address_ADDR_ID coming from (4)

If I am wrong then please advise as to what you are trying to do.


Messages In This Thread
Can't write data into database - by El Forum - 01-16-2011, 12:17 PM
Can't write data into database - by El Forum - 01-16-2011, 02:42 PM
Can't write data into database - by El Forum - 01-16-2011, 02:51 PM
Can't write data into database - by El Forum - 01-16-2011, 03:09 PM
Can't write data into database - by El Forum - 01-16-2011, 03:25 PM
Can't write data into database - by El Forum - 01-16-2011, 03:50 PM
Can't write data into database - by El Forum - 01-16-2011, 04:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB