CodeIgniter Forums
Can Hooks be used to capture all CUD operations in CI3? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Can Hooks be used to capture all CUD operations in CI3? (/showthread.php?tid=80257)



Can Hooks be used to capture all CUD operations in CI3? - Ahirsi - 10-08-2021

I have a CodeIgniter 3 application and would like to create an audit trail of all CUD operations and save them
to individual audit tables.

Under each CUD statement in the code I wrote $this->db->last_query() to capture the query and save it to an audit table
together with the table name, operation type.

My question is how can I use CI hooks to accomplish the same. Is that even the proper use or capability of hooks?

Is it possible to grab each CUD query that is run including the relevant controller and method the query exists in?

How can that be setup?

AHirsi