Book Image

Magento PHP Developer????s Guide, 2nd Edition

By : Allan MacGregor
Book Image

Magento PHP Developer????s Guide, 2nd Edition

By: Allan MacGregor

Overview of this book

Table of Contents (16 chapters)
Magento PHP Developer's Guide Second Edition
About the Author
About the Reviewers

Using Direct SQL

So far we have learned how Magento data models and ORM systems provide a clean and simple way to access, store, and manipulate our data. Before we jump right into this section and learn about the Magento database adapters and how to run raw SQL queries, I feel it is important that we understand why you should avoid using what you are about to learn in this section as much as possible.

Magento is an extremely complex system, and as we've also learned in the previous chapter, a framework driven in part by events. Just saving a product will trigger half a dozen different events, each doing a different task. This will not happen if you decide to just create a query and update a product directly. So, as developers, we must be extremely careful and be sure there is a justifiable reason to go outside the ORM.

That said, there are of course scenarios when being able to work with the database directly comes in extremely handy and is actually simpler than working with the Magento models...