Esempio n. 1
0
 /**
  * Get join info query for current condition;
  * @param bool $forCount
  * @return string
  */
 public function getJoin($forCount = false)
 {
     if (!$this->with) {
         return $this->join;
     }
     if (!$this->relationsParser) {
         $this->relationsParser = RelationsParser::parse($this->model, $this, $this->conditionColumns);
     }
     return ($forCount ? $this->relationsParser->getForCount() : $this->relationsParser->getForMainSelect()) . ' ' . $this->join;
 }
Esempio n. 2
0
 /**
  * Reads all relations for current model.
  * @param $name
  * @return DbModel[]|DbModel
  */
 private function getRelationFromDb($name)
 {
     if (!$this->relationsParser) {
         $this->relationsParser = RelationsParser::parse(get_class($this), new ModelCondition(['model' => get_class($this)]), '*');
     }
     return $this->relationsParser->getForSingleModel($this, $name);
 }