"Pure" SQL in a web project

Long interested in the question of what is more commonly used in web projects? SQL in its pure form, or more common ORM? Propose to exclude from the reporting options sites-business cards, homepage, etc.
If anyone can share a story why he used one and went to another — even better.
October 3rd 19 at 02:19
6 answers
October 3rd 19 at 02:21
Only the ORM (and it is possible to use the full power of SQL when it's needed).
I think that at a fraction of the percentage of projects (hayload) you can use pure SQL, but in other cases it is not necessary, and should prefer more convenient and faster method: ORM.
However, I would not be so categorical!
Several times faced with the fact that the orm generates such a horrible request that I want to swear bad words. - christy_Hessel commented on October 3rd 19 at 02:24
avorsa, you should know in advance which query will be generated ORM.
Bad request no matter what ORM are bad and that they do not know how to use it. - toni commented on October 3rd 19 at 02:27
October 3rd 19 at 02:23
Use depending on the situation when working with a single object ORM, convenient and intuitive. Complex queries or queries ORM eats a lot of RAM or other resources, pure and simple.
Team development? Or are you one lead the entire project? - christy_Hessel commented on October 3rd 19 at 02:26
3 programmer, about 100 thousand lines. - toni commented on October 3rd 19 at 02:29
October 3rd 19 at 02:25
Often both approaches. Not infrequently both in the same project.

Used both approaches. For simple things without the emphasis on performance — ORM, but ORM is not rare does not effective SQL queries.
Now almost only the ORM, demanding proizvoditelnosti in PHP do not write.
October 3rd 19 at 02:27
Heavy sample — in stored procedures (MSSQL), and for simpler things — a good QueryBuilder with a wrapper for the db driver. Net SQL in code I haven't seen. The correct formatting of the query, parameters, connection etc should be passed on to the shoulders of other libraries. And yet, a good QueryBuilder creates an additional level of abstraction between the query and the database driver, therefore we let this go, and so it may be even a different database to use, for example SQLite instead of mssql
October 3rd 19 at 02:29
Pure SQL queries use multi-storey where a significant portion of application logic is concentrated in the database. This application can have a web muzzle, but it's not the same as web-based application. Application logic in the database (i.e., manipulating exact data within the relational schema, and not I/O, peripherals, storage cache etc.) are applications of intranets that bad massturbate between servers: accountancy, billing, customer database, inventory, etc.
In addition, applications for the SQL you need to test in a different method than applications in a functional or object-oriented language. So the ORM in web projects is justified. - christy_Hessel commented on October 3rd 19 at 02:32
October 3rd 19 at 02:31
If you create a structure such as "object-oriented", with data storage in the database, then for such objects it is more logical to use simple queries. The queries start to get complicated when the complexity of the objects: the object includes many other objects and that would save time for access to the database uses a complex query.

As complex queries can trebuutsya in the preparation of reports and other beautifying things.

Just try these approaches to proceed from simplicity. The simpler it is written, the easier to tune and easier to control. And speed wins.

Find more questions by tags SQLORM