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.
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.
carlee answered on 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.
Lilla99 answered on 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.
keshawn_Goodwin answered on 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
alice_Swaniawski answered on 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.
Mariana.Mor answered on 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.