Answer the question
In order to leave comments, you need to log in
passing extra parameters to insert/update postgresql
Good time!
Such a task is worth it - there is a devices table, there is a device_log table. When devices are changed by triggers, an event is written to the log.
Now the task becomes more complicated - we hang editing the values partially on the web-muzzle with separation of rights. At the same time, you need to know who performed this or that action. I don’t see the point in writing new functions - triggers in the database do their job perfectly. I would like to pass the $_SESSION['user_id'] parameter to insert/update queries. But how?
Answer the question
In order to leave comments, you need to log in
What is it that bothers you? :)
pg_query($conn, "INSERT INTO device_log (user_id) VALUES ({$_SESSION['user_id']})");
You can add a field to devices, like modified_by , that will store the last user who changed the record. Then the user will also be available in the trigger, and it will be possible to add him to the log.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question