O
O
Onatsky2016-12-02 18:48:41
PHP
Onatsky, 2016-12-02 18:48:41

Relationship between two tables?

There are users and settings tables.
The users table has an id column with auto-increment
How to make it so that when adding a record to the users table, a record with the same id is created in the settigns table at the same time?
Previously, I used the fact that creating a record in one of the tables, I recognized the last_insert_id, and then created a record in another table substituting this id. But did I do it right? How to implement it more correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max, 2016-12-02
@MaxDukov

the trigger on the users table on insert will not approach?

S
Stanislav Makarov, 2016-12-02
@Nipheris

What is the purpose of the record? Well, when you receive a request to save the settings, then write it down (an upsert-analogue in mysql, like on duplicate key), and substitute the defaults.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question