Welcome Guest, Not a member yet? Register   Sign In
Inserting/Updating "Userstamps" from a Model
#1

I am beginning a new project in CI4 where one of the requirement is to track when a table row is created and/or updated by particular user.  This should behave like the CI4 Model's "created_at" and "updated_at" timestamp columns.  I have similarly created database columns called "created_by" and "updated_by" for each table.  It is simple enough to add these columns to the $allowedFields array and pass the user_id value from the session to the model using the controller, but that does not seem proper.  Ideally these fields should behave in a similar way to $createdField and $updatedField where the model automatically grabs the user_id value from the session and inserts or updates that value when appropriate.  I am relatively new to CodeIgniter and frameworks in general.  I am unsure of the best way to achieve this.  I'm hoping someone with more experience can point me in the right direction.  Thank you in advance.
Reply


Messages In This Thread
Inserting/Updating "Userstamps" from a Model - by mlurie - 08-18-2020, 02:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB