• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need opinions: trigger or model ?

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 .

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.

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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.