Ejemplo n.º 1
0
 public function mergeWith($criteria, $fromScope = false)
 {
     if ($criteria instanceof CDbCriteria) {
         $criteria = $criteria->toArray();
     }
     if ($fromScope) {
         if (isset($criteria['condition']) && $this->on !== $criteria['condition']) {
             if ($this->on === '') {
                 $this->on = $criteria['condition'];
             } elseif ($criteria['condition'] !== '') {
                 $this->on = "({$this->on}) AND ({$criteria['condition']})";
             }
         }
         unset($criteria['condition']);
     }
     parent::mergeWith($criteria);
     if (isset($criteria['joinType'])) {
         $this->joinType = $criteria['joinType'];
     }
     if (isset($criteria['on']) && $this->on !== $criteria['on']) {
         if ($this->on === '') {
             $this->on = $criteria['on'];
         } elseif ($criteria['on'] !== '') {
             $this->on = "({$this->on}) AND ({$criteria['on']})";
         }
     }
     if (isset($criteria['with'])) {
         $this->with = $criteria['with'];
     }
     if (isset($criteria['alias'])) {
         $this->alias = $criteria['alias'];
     }
     if (isset($criteria['together'])) {
         $this->together = $criteria['together'];
     }
 }
Ejemplo n.º 2
0
 /**
  * Merges this relation with a criteria specified dynamically.
  * @param array the dynamically specified criteria
  * @since 1.0.5
  */
 public function mergeWith($criteria)
 {
     parent::mergeWith($criteria);
     if (isset($criteria['joinType'])) {
         $this->joinType = $criteria['joinType'];
     }
     if (isset($criteria['on']) && $this->on !== $criteria['on']) {
         if ($this->on === '') {
             $this->on = $criteria['on'];
         } else {
             if ($criteria['on'] !== '') {
                 $this->on = "({$this->on}) AND ({$criteria['on']})";
             }
         }
     }
     if (isset($criteria['with'])) {
         $this->with = $criteria['with'];
     }
     if (isset($criteria['alias'])) {
         $this->alias = $criteria['alias'];
     }
     if (isset($criteria['together'])) {
         $this->together = $criteria['together'];
     }
 }