All pastes #1422778 Raw Edit

Thomas

public php v1 · immutable
#1422778 ·published 2009-05-14 16:15 UTC
rendered paste body
/** * Creates an (INNER|LEFT) JOIN with a multiple ON clause * Basically this is the same like * $finder->addJoin($left_columns, $right_columns, $operator) * would do (this call is passed through to the adapter by DbFinder) * but by also recording the relation we're setting up here, so * the finder can properly hydrate related objects in that way as well * * @param $class string Name of the class to join * @param $left_columns mixed either a single value or an array of left columns * @param $right_columns mixed either a single value or an array of right columns * @return itcPropelFinder instance */public function multiJoin($class, $left_columns = null, $right_columns = null, $operator = Criteria::INNER_JOIN){    list($relatedClass, $alias) = $this->getClassAndAlias($class);    $relatedPeerClass = sfPropelFinderUtils::getPeerClassFromClass($relatedClass);    if (!$this->hasRelation($relatedPeerClass))    {        $this->addRelation($relatedPeerClass, $alias);    }    if (empty($left_columns) || empty($right_columns))    {        list($left_columns, $right_columns) = $this->getRelation($relatedClass);    }    else    {        for ($i=0; $i<count($left_columns); $i++)        {            $arg = explode(".", $left_columns[$i]);            if (count($arg) == 2)            {                $peerClass = sfPropelFinderUtils::getPeerClassFromClass($arg[0]);                if ($this->hasRelation($peerClass))                {                    $left_columns[$i] = $this->getColName($arg[1], $peerClass);                }            }        }        for ($i=0; $i<count($right_columns); $i++)        {            $arg = explode(".", $right_columns[$i]);            if (count($arg) == 2)            {                $peerClass = sfPropelFinderUtils::getPeerClassFromClass($arg[0]);                if ($this->hasRelation($peerClass))                {                    $right_columns[$i] = $this->getColName($arg[1], $peerClass);                }            }        }    }    $this->criteria->addJoin($left_columns, $right_columns, $operator);    return $this;}