Reputation: 1122
I am trying to insert some user registration data into my data table.
u_id | name | username | password | email
$res = pg_query("INSERT INTO mfbusers (name, username, password, email) VALUES ('$name', '$username', '$password', '$email') RETURNING u_id");
I'm really not sure how to then use the returned u_id to insert into the u_id column. I have tried the Data Modifying CTE method but that logic only makes sense to me when I have multiple tables with a relational database.
Any suggestions on how to insert the u_id
value into the u_id
column?
All the other variables are written properly into my database. It's just the u_id
column is blank upon registration.
Upvotes: 0
Views: 99
Reputation: 2748
Change your u_id column to SERIAL and the values will be assigned automatically
Upvotes: 3