Welcome Guest, Not a member yet? Register   Sign In
Poll: Straight PHP or SQL Trigger
You do not have permission to vote in this poll.
PHP All the way!
80.00%
4 80.00%
SQL Triggers
20.00%
1 20.00%
Total 5 vote(s) 100%
* You voted for this item. [Show Results]

Database - Triggers or no Triggers?
#3

(08-27-2015, 12:11 PM)mwhitney Wrote: I usually handle this in the model through PHP. The only real reasons I can think of for this preference are:
- I don't have to rewrite the triggers if I change databases (not a likely occurrence for me, but it was one of the reasons)
- I can code the behavior once in my base model (or, in this case, most of the code was written by someone else) and control whether it's used on a particular model with a boolean value, rather than defining a new set of triggers for each table.

I'm sure if I really put my mind to it I could find a way to easily define the triggers in any supported database, but I really didn't give the option much thought when I made the decision (I really didn't even give it enough consideration to think of it as a conscious choice).

Reason #1 might be the reason I end up switching from Triggers back to PHP. This app will be installed by other people on their own servers with their own database accounts. So the database schema/dump will need to NOT have the triggers in it, and the installation script will need to add the triggers as the correct user, or else the database backup that I will provide will try to create the triggers as my user.

If something happens in the setup, and the portion that creates the triggers doesnt run, that will mess with a LOT of things
Reply


Messages In This Thread
Database - Triggers or no Triggers? - by jLinux - 08-27-2015, 10:55 AM
RE: Database - Triggers or no Triggers? - by jLinux - 08-27-2015, 12:34 PM
RE: Database - Triggers or no Triggers? - by Narf - 09-01-2015, 02:16 AM
RE: Database - Triggers or no Triggers? - by Narf - 09-01-2015, 05:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB