Stored procedures a no-go in the php/mysql world?

前端 未结 10 1559
粉色の甜心
粉色の甜心 2020-12-29 06:53

I\'m quoting part of an answer which I received for another question of mine:

In the PHP/MySQL world I would say stored procedures are no-go

相关标签:
10条回答
  • 2020-12-29 07:23

    I would not say "stored procedures are a no-go", I would say "Don't use them without a good reason".

    MySQL stored procedures have a particularly horrible syntax (Oracle and MSSQL are pretty awful too), maintaining them just complicates your application.

    Do use a stored procedure if you have a real (measurable) reason to do so, otherwise don't. That's my opinion anyway.

    0 讨论(0)
  • 2020-12-29 07:24

    There's possibly a phobia of stored procedures with mysql, partly due to not being overwhelmingly powerful ( compared to Postgresql and even MSSQL, mysqls stored procedures are greatly lacking ).

    On the plus: They make interfacing with it from more than one language easier.

    If somebody states that "using stored procedures is bad because its not portable to different databases" then this of course means they think you're likely to switch databases, which means they in turn saying they think you shouldn't be using mysql.

    It is popular to use ORM's these days, but I personally think ORM is a BadThing (Question:82882)

    0 讨论(0)
  • 2020-12-29 07:24

    I think that using stored procedures can offer some abstraction in certain applications, as in any where you would use the same SQL code chunk to update or add the same data, you could then create the one sproc save_user($attr.....) rather that repeating yourself all over the place.

    Agreed the syntax is hairy and if your used to MSSQL and oracle sprocs there are differences that can fustrate.

    0 讨论(0)
  • 2020-12-29 07:27

    This is a subjective question.

    I would personally include all calculations within PHP and only really use MySQL as a table.

    But, If you feel that it is easier to use stored procedures then by all means, go ahead and do it.

    0 讨论(0)
提交回复
热议问题