yii\db\ActiveQuery::populate PHP Method

populate() public method

public populate ( $rows )
    public function populate($rows)
    {
        if (empty($rows)) {
            return [];
        }
        $models = $this->createModels($rows);
        if (!empty($this->join) && $this->indexBy === null) {
            $models = $this->removeDuplicatedModels($models);
        }
        if (!empty($this->with)) {
            $this->findWith($this->with, $models);
        }
        if ($this->inverseOf !== null) {
            $this->addInverseRelations($models);
        }
        if (!$this->asArray) {
            foreach ($models as $model) {
                $model->afterFind();
            }
        }
        return $models;
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  */
 public function populate($rows)
 {
     $event = new PopulateEvent($this, $rows);
     $this->trigger(static::EVENT_BEFORE_POPULATE, $event);
     $rows = $event->rows;
     return parent::populate($rows);
 }
All Usage Examples Of yii\db\ActiveQuery::populate