Taking A Look At Propel 1.5

« »

Anyone who knows me knows that when I talk about the model, I’m usually talking about Propel. I’ve liked Propel ever since I started working with it in the middle of last year; I personally find it easier and more fun to use than Doctrine or other ORMs available today. I was excited to see recently that Propel’s development team had released Propel 1.5 as a beta, with a launch of the new features to come soon.

There are a couple new features in Propel 1.5 that I think are going to be pretty awesome additions. Here are my two favorites:

Collections and On-Demand Hydration
One of the things you’d sometimes have to do with Propel is fetch an array of objects and iterate through that array to find the data you wanted. However, this created a significant concern: it actually had to hydrate these objects all at the same time. This means that if you had a limit of, say, 200,000, you could quite possibly run out of memory.

Propel 1.5 adds the ability to have the Collection object hydrate the objects on demand, rather than all at once. This saves memory until the object is actually requested. Propel is smart enough not to need to run back and forth to the database; it still has access to the results set, but doesn’t hydrate the objects until it needs them.

Model Queries
Prior to Propel 1.5, in order to query the database in any unusual way (say, attaching an unusual WHERE clause for example), you had to use a Criteria object. Criteria objects were exceptionally useful, but had certain limitations, the largest one being that they are unaware of the way the model is constructed, and therefore cannot offer additional help at building queries.

With the introduction of Propel 1.5, there is a new set of classes automatically generated called Query classes. These classes extend the Criteria class, incorporating it’s functionality while offering helper methods that make writing common queries easier. For example, if you’re searching for a user you can find that user more easily because there will be a method named findByUsername() that you can access.

These features, along with lots of other cool components, make Propel 1.5 pretty awesome. I’m looking forward to it’s stable release and to integrating it into my development in the near future.

Brandon Savage is the author of Mastering Object Oriented PHP and Practical Design Patterns in PHP

Posted on 2/23/2010 at 10:58 pm
Categories: Technology, General PHP
Tags: , , ,

Jake Smith (@jakefolio) wrote at 2/24/2010 4:37 pm:

Is Propel getting rid of the Peer classes?

The last time I used Propel was 2008, which I believe was 1.1 or 1.2. I found writing queries in Propel to be much more tedious than doctrine. I’m glad Propel is making strides to improve.

Didn’t Propel go stagnant for a while?

Brandon Savage (@brandonsavage) wrote at 2/24/2010 4:42 pm:

According to the docs, these Query classes will eventually eliminate Peer classes, but don’t do so yet. Peer classes will eventually become deprecated from what I understand. It’s important to note, however, that Query classes extend Criteria objects; Peer classes extend BasePeer.

Propel did go stagnant for a while. The person who was responsible for Propel’s development essentially moved on, and after a while named a successor, who has not been leading the charge to reinvigorate Propel.

Jonathan Nieto (@johannieto) wrote at 2/25/2010 4:59 pm:

When starting with symfony I started with Propel, too. Back that time it was the best choice because Doctrine was pretty unstable. But now Doctrine 1 is very stable. Based on all the features Doctrine has to offer I started to use it almost a year ago.

These two additions for Propel are already done in Doctrine, so my question is why not to start using doctrine. I really would like to know your reasons for using Propel.


« »

Copyright © 2024 by Brandon Savage. All rights reserved.