Welcome Guest, Not a member yet? Register   Sign In
need opinions: trigger or model ?
#1

[eluser]adwin[/eluser]
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 .
#2

[eluser]inari[/eluser]
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.
#3

[eluser]gtech[/eluser]
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.




Theme © iAndrew 2016 - Forum software by © MyBB