5

When I start query data from database I don't know what way I should use Eloquent or Query Builder. what is the best choice? Eloquent is write less than Query builder but I cannot control input field while Query builder write more but I can manual input field by myself. What something else do I have to know more about them?

SRENG Khorn
  • 1,201
  • 1
  • 12
  • 22
  • An important difference can be performance: https://stackoverflow.com/questions/38391710/laravel-eloquent-vs-query-builder-why-use-eloquent-to-decrease-performance/48358140#48358140 – Mohammad Naji Jan 20 '18 at 16:03

1 Answers1

8

There is not best choice. The choice depends entirely in your needs. Using Eloquent has the advantages of using an ORM, and its disadvantages.

In general, the main advantage of Eloquent against query builder is the speed of development. And that reduces development cost.

The main disadvantage is that the ORMs tend to be slower, and that the developer is less in control of the database management.

For most projects, where no very complex queries are needed, the best is start using ORM. Afterwards, if you are in the need of optimise the app, you can translate them to queries that will perform better.

Postizo
  • 128
  • 5