CodeIgniter Forums
need opinions: trigger or model ? - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: need opinions: trigger or model ? (/thread-7724.html)

need opinions: trigger or model ? - El Forum - 04-20-2008

I am used to do programming using Oracle Triggers but right now I must work with MySQL db.
I know that MySQL Db is quite new in Triggers and stored procedure. I was thinking should I use MYSQL trigger or using procedural/method that implemented in Model ?

what is the best solutions. can CI model immite like what trigger does ?

for example each CI model has method for doing something before/after inserting/updating/deleting data ... so those method will be called right before/after the specific record updated also can it "rollback" when something wrong happened.

Thanks .

need opinions: trigger or model ? - El Forum - 04-23-2008

You should use them just as you did with ora. There is really no difference. Or I just can't see it. Smile

CI models don't emulate triggers.

need opinions: trigger or model ? - El Forum - 04-23-2008

I use triggers in MYSQL and they work fine.. the added advantage of using the database trigger is that it gets fired even when data is modified using the MYSQL CLI, as you probably are aware.

If your just after rollbacks then transactions work well in CodeIgniter, (db_debug has to be set to FALSE in the config/database.php file).. be sure to set the table types as innodb.

if you use a transaction you can also check to see if a transaction was unsuccessful/successful and call the relevant function.

However I am unaware of a method that allows you to call a CI controller/model function when a database trigger is activated.