Junior — Middle
Have you used SQL in conjunction with ORM in your projects?
sobes.tech AI
Answer from AI
Yes, when working with ORM in PHP (such as Doctrine or Eloquent), it is often necessary to use SQL queries directly for optimization or to implement complex logic that is difficult to express with ORM tools. For example, you can write custom queries using the createQuery or raw methods to perform specific operations.
Example with Eloquent:
$users = DB::select('SELECT * FROM users WHERE active = ?', [1]);
This approach helps improve performance and flexibility when standard ORM methods are insufficient.