How to make sfPropelCustomJoinHelper work with propel1.3?

sfPropelCustomJoinHelper is one of my favorite classes.. It’s saved me from writing headache propel joins. But it was designed to work only with propel 1.2.
So, how to make it work with propel 1.3?. Yes, you are right, extends it and override some functions.

There is no way to override hydrate function of sfPropelCustomJoinObjectProxy, because rs parameter is restricted to Resultset type.

class mysfPropelCustomJoinObjectProxy extends sfPropelCustomJoinObjectProxy
  public function myHydrate($rs, $startcol = 0)
     $startcol = $this->obj->hydrate($rs, $startcol);
     return $startcol;

class mysfPropelCustomJoinHelper extends sfPropelCustomJoinHelper
  public function __construct($mainClassName)

  public function doSelect($c, $con=null)
    $rs = $this->doSelectRS($c, $con=null);
    $a = array();
    while ($row = $rs->fetch(PDO::FETCH_NUM)) {
	$a[] = $this->hydrate($row, 0);
    return $a;

  public function doSelectRS($criteria, $con=null)
    $c = clone $criteria;
    call_user_func(array($this->mainClassName.'Peer', 'addSelectColumns'), $c);
    foreach ($this->selectClasses as $className) {
      call_user_func(array($className.'Peer', 'addSelectColumns'), $c);
    $rs = call_user_func_array(array($this->mainClassName.'Peer', 'doSelectStmt'), array($c, $con));
    return $rs;

  public function hydrate($rs, $startCol=1)
    $obj = new mysfPropelCustomJoinObjectProxy($this, $this->mainClassName);
    $startCol = $obj->myHydrate($rs, $startCol);
    $childObjs = array();
    foreach ($this->selectClasses as $className)
      $childObj = new mysfPropelCustomJoinObjectProxy($this, $className);
      $startCol = $childObj->myHydrate($rs, $startCol);
      if ($childObj->isAllPrimaryKeyNull())
        $childObjs[$className] = null;
        $childObjs[$className] = $childObj;
    foreach ($childObjs as $childClassName => $childObj)
      $obj->addExternalObject($childObj, $childClassName); //main class object always holds all child objects.
      if (isset($this->classOwnership[$childClassName]))
        foreach ($this->classOwnership[$childClassName] as $tmp)
          if (array_key_exists($tmp[0], $childObjs))
            $childObj->addExternalObject($childObjs[$tmp[0]], $tmp[1]);
    return $obj;

Sorry for my bad english :D..
I hope it help.

3 responses to “How to make sfPropelCustomJoinHelper work with propel1.3?

  1. Pingback: Smart paging for an array of elements using sfPropelCustomJoinHelper « Just Blog no more…

  2. Piko January 22, 2010 at 5:44 pm

    thank you Mr. Yunan you save me, you’re my HERO…. Hahahaha

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: