/** * @param array $options * * @return LazyLoader */ public function getLazyLoader(array $options) { $fk = $this->getForeignKey(); $pk = $this->owner->getPrimaryKey(); $ids = $options['ids']; $with = $options['with']; $callback = $options['callback']; $immediate = $options['immediate']; $select = new Select($this->compiler, $this->model->getTable()); $select->where($fk)->in($ids); if ($callback !== null) { $callback($select); } $query = (string) $select; $params = $select->getCompiler()->getParams(); return new LazyLoader($this->connection, $query, $params, $with, $immediate, $this->isReadOnly, $this->hasMany(), get_class($this->model), $fk, $pk); }
public function __construct(Connection $connection, Model $model) { $this->model = $model; $this->connection = $connection; $compiler = $connection->compiler(); $query = new Select($compiler, $model->getTable()); $whereCondition = new WhereCondition($this, $query); parent::__construct($compiler, $query, $whereCondition); }