/** * Constructor. * @param CJoinElement $joinElement The root join tree. * @param CDbCriteria $criteria the query criteria */ public function __construct($joinElement, $criteria = null) { if ($criteria !== null) { $this->selects[] = $joinElement->getColumnSelect($criteria->select); $this->joins[] = $joinElement->getTableNameWithAlias(); $this->joins[] = $criteria->join; $this->conditions[] = $criteria->condition; $this->orders[] = $criteria->order; $this->groups[] = $criteria->group; $this->havings[] = $criteria->having; $this->limit = $criteria->limit; $this->offset = $criteria->offset; $this->params = $criteria->params; if (!$this->distinct && $criteria->distinct) { $this->distinct = true; } } else { $this->selects[] = $joinElement->getPrimaryKeySelect(); $this->joins[] = $joinElement->getTableNameWithAlias(); $this->conditions[] = $joinElement->getPrimaryKeyRange(); } $this->elements[$joinElement->id] = true; }