Support the ongoing development of Laravel.io →
Database Eloquent Architecture
Last updated 2 years ago.
0

He has a few points and is correct on a few of them, however he ignores a pretty important point when it comes to building applications:

  1. Readability and
  2. Maintainability

Using an ORM solution means you are also much more secure by default (you don't need to worry about escaping user input.etc. as it's already taken care of).

Really, you should only be worrying about performance issues in respect to ORMs if and WHEN you encounter them.

Also, his point about #2 isn't always true. Quite often it's faster to execute 2 separate queries rather than 1 (especially in the case of complex joins).

I don't understand point #4 either.

Last updated 2 years ago.
0

Ask him to change the DB from the current one to another one (for example, from MySQL to Postgres), then show him the pains of changing his raw sql. (grin)

0

With the same logic, he could as well make the entire website in pure procedural PHP, and everything would run a lot faster. But Eloquent is there for the same reason as PHP frameworks like Laravel: security, ease of use and maintainability.

Also, with Eloquent and DB:raw you can do pretty much whatever you want:

$foo = Foo::orderByRaw('DATEDIFF(date_begin, NOW())');
$bar = Bar::select(['bar.*', 'p.date_begin'])
	->from( DB::raw("bar, ({$foo->toSql()}) p") )
	->get();
0

Both @shinsenter and @Cyril make valid points. If for some reason you should ever have to change the DB server to a different SQL server, eloquent is going to make that worlds easier. And he can still make raw DB calls when he feels he needs to with eloquent.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.