Book Image

Learning Phalcon PHP

Book Image

Learning Phalcon PHP

Overview of this book

Table of Contents (17 chapters)
Learning Phalcon PHP
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

ORM – drawbacks and caching


If you are developing a small-to-medium project, or if you are working with a big team of developers (more than three), using an ORM—in general—is a good idea. This is because firstly, it forces you to follow some rules, and secondly, the development will be much faster.

Let's take as an example the SELECT * FROM article query . Using a raw query, the MySQL log will return you this:

141214 23:35:53    572 Connect  root@localhost on
      572 Query  select @@version_comment limit 1
      572 Query  SELECT DATABASE()
      572 Init DB  learning_phalcon
      572 Query  SELECT * FROM article
      572 Quit

By using the ORM and the find() method, your MySQL log will look like the following:

141214 23:37:26    490 Query  SELECT IF(COUNT(*)>0, 1 , 0) FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME`='article'
      490 Query  DESCRIBE `article`
      490 Query  SELECT `article`.`id`, `article`.`article_short_title`, `article`.`article_long_title`, `article`.`article_slug...