Welcome Guest, Not a member yet? Register   Sign In
how do we use multiple tables entry in codeigniter
#1

[eluser]Sakthi MCA[/eluser]
how can we use multiple tables entry in codeigniter.please give reply immediately.
it is very urgent
#2

[eluser]jedd[/eluser]
have you got one table entry working okay already?
#3

[eluser]Sakthi MCA[/eluser]
i am new to codeigniter.
yes one table entry is working.
i have two tables
one is User_table. it contains user_id (primary,Auto increment) ,User_name and password.
another is profile_table. profile _id(primary,Auto increment) ,user_id ,User_name and password.
i need to store last inserted value of user_id in User_table to user_id field of profile_table.

how can i do in codeigniter

let me know please
#4

[eluser]jedd[/eluser]
Quote: i have two tables
one is User_table. it contains user_id (primary,Auto increment) ,User_name and password.
another is profile_table. profile _id(primary,Auto increment) ,user_id ,User_name and password.

Do you really have User_name and password columns replicated in those two tables?

In any case, you have a user.id (either because you've just done an insert, or a select to find the row you want). And then you do an insert or update query on your profile table and put that value in.

I'm unsure where you're getting stuck. Can you post the model code you've got so far for your insert?
#5

[eluser]jedd[/eluser]
Oh, by the way, how many profiles can one user have?

If your answer is '1' - my next question will be: Why isn't profile_id part of the user table?
#6

[eluser]Sakthi MCA[/eluser]
two profiles

one profile for normal user subscription ie user_table
another for paid user ie profile_table
#7

[eluser]rogierb[/eluser]
To get the last inserted id, use <code>$new_id = $this->db->insert_id();</code> after doing the insert.

Then use that $new_id to update the profile_table.
#8

[eluser]jedd[/eluser]
[quote author="Sakthi MCA" date="1248891104"]two profiles

one profile for normal user subscription ie user_table
another for paid user ie profile_table[/quote]

Do you mean a user can actually have just one profile (but it can be one of two types) or actually have two different profiles at the same time?

If the former, then your schema is probably broken.

If the latter .. well, your schema is probably broken there too. Wink




Theme © iAndrew 2016 - Forum software by © MyBB