/** * Return list of columns to select from current tables; * @return string[] * @throws \Exception */ protected function getAllColumnsForSelect() { $with = is_array($this->with) ? $this->with : ($this->with ? explode(',', $this->with) : array()); if (!count($with)) { return ['*']; } $model = $this->model; $db = $model::getDb(); $columns = $this->_columnsForModel($model::getTableName(), $db); foreach ($this->relationsParser->getListOfSelectedRelations() as $name => $relation) { $cols = $this->_columnsForRelation($relation, $db, $name); foreach ($cols as $column) { $columns[] = $column; } } return $columns; }
/** * 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); }