On 11/10/2010 16:37, Rob Marscher wrote:
On Nov 10, 2010, at 3:31 PM, Jerry B. Altzman wrote:
I know that in the commercial database world use of stored procedures is The 
Way Things Are Pretty Much Done, but I've not seen it in my brief forays 
through the bulk of PHP code I've examined (and needless to say, written). Am I 
just out of it? Is it just not considered usual practice, or am I blind?

Personally, I think stored procedures are useful when you have DBAs in control 
of the database and critical business logic and they don't trust the developers 
interacting with the data.  Also useful if you have several different codebases 
acting on the data.  A lot of php code is done with the least common 
denominator in mind (i.e. somebody on a free shared hosting account), so it 
won't take advantage of the advanced tools available (non-default extensions, 
db features that require more recent versions of mysql [although most are 
probably on 5.0+ now], etc).

However, if you do essentially have one codebase doing all of your data 
manipulation and you don't have dedicated DBAs, I think using stored procedures 
doesn't really make sense because it's dividing up where your business logic is 
located and potentially making things more confusing or harder to debug.


It also depends on how many systems access your database and perform more or less the same tasks. If you have a dozen systems accessing the same database then shifting business logic and tasks to the database server will make it work the same across all systems. That way you don't have to reinvent the wheel and keep it pumped up on every system. Also, sprocs can help distributing processing load from the web server to the database server. Depending on how the systems are used that may be a benefit. Besides that, sprocs can be used by other apps that are not written in PHP whereas your PHP code cannot. Then again, why would anyone use something other than PHP....


David
_______________________________________________
New York PHP Users Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/Show-Participation

Reply via email to