2

I am working on a reports module and I've noticed that running direct SQL queries is quite faster than using Magento methods for retrieving a collection.

Is there any disadvantage to executing direct SQL queries?

3
  • 1
    The biggest problem is security. IF you know what you are doing all is fine. You know how to secure SQL queries? Dec 9, 2014 at 8:48
  • I know how to secure SQL queries, thanks. I am worried that Magento may change the table structures in future versions.
    – LorenzoR
    Dec 9, 2014 at 20:43
  • 1
    This problem isn't solved by using explicit column names in collections too. Dec 11, 2014 at 8:31

1 Answer 1

1

Though it is not good practice, sometimes, you may need to execute direct SQL queries in Magento. However, be careful! The Magento model's are there for a reason and provide a layer of security which you will have to manually add to your own direct SQL queries. Using execute direct SQL queries, its architecture will be messed and be hard to develop any feature. It is better to learn Magento architecture more before developing, though it is tedious job!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.