php - 何时在 Laravel 5.x 中编写存储过程

标签 php mysql laravel stored-procedures laravel-5

我知道这与特定错误无关。但我很想知道什么时候应该在 laravel 中使用存储过程?我读了几篇文章。以下是摘要。根据这篇文章Advantages and Drawbacks of Using Stored Procedures for Processing Data这些程序各有利弊。毫无疑问,使用存储过程会提高速度(抱歉我缺乏知识),但我想到了一件事:

存储过程的替代方案

这里有两种选择

  1. 内联或参数化查询
  2. 对象关系映射 (ORM)

我是如何知道LARAVEL拥有最好的抽象数据库使用的,毫无疑问,我在编写存储过程方面还不够好。谁能建议我是否需要编写存储过程?如果是的话什么时候?

这是上面文章的正文

Stored Procedures may not always be the right answer for processing data, but there’s also not enough compelling evidence to not use them either. Whether or not to use them determines on your particular situation and ability to develop the Stored Procedure(s) to match. Just like with writing a good, quality application, if you or your developers can write good, quality Stored Procedures, then by all means implement them. If they can’t, then another solution might be best for you.

任何指导都会对我有很大帮助。 :)

最佳答案

坚持使用 laravels 默认的 eloquent ORM。如果您发现您需要使用事件记录模式无法获得的功能,请研究一下原则。我不会使用存储过程,除非出于性能原因您希望在数据库服务器上编译一个特别复杂的查询。

过早的优化是项目 killer 。

关于php - 何时在 Laravel 5.x 中编写存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38918848/

相关文章:

php - .serialize() 方法添加\r 到换行符?

php mysql 事务回滚疑惑

php - 如何从 php 连接到 mysql?

mysql - 建mysql数据库时collat​​ion字段中不同语言的意义是什么

mysql 5.5 - 数据库定期崩溃(每周 1-2 次)

mysql - WHERE子句导致Mysql查询语法错误

php - Laravel Eloquent - pluck() 角色名称

php - linux shell 脚本 : how can I create a service that will run in background?

database - Laravel - 在验证唯一性时从登录用户中排除该行

php - Laravel 5.2 获取Linux系统环境变量