/** * Begin a fluent query against a database table. * * @param string $table * * @return \Illuminate\Database\Query\Builder */ public function table($table) { $processor = $this->getPostProcessor(); $table = $this->db->prefix . $table; $query = new Builder($this, $this->getQueryGrammar(), $processor); return $query->from($table); }
/** * Set the collection which the query is targeting. * * @param string $table * * @return Builder */ public function from($table) { if ($table) { $this->table = r\table($table); $this->query->table($table); } return parent::from($table); }
/** * Set the table which the query is targeting. * * @param string $table * @return $this * @static */ public static function from($table) { return \Illuminate\Database\Query\Builder::from($table); }
/** * Set a model instance for the model being queried. * * @param \Illuminate\Database\Eloquent\Model $model * @return \Illuminate\Database\Eloquent\Builder */ public function setModel(Model $model) { $this->model = $model; $this->query->from($model->getTable()); return $this; }
/** * Set the collection which the query is targeting. * * @param string $collection * @return Builder */ public function from($collection) { if ($collection) { $this->collection = $this->connection->getCollection($collection); } return parent::from($collection); }
/** * Init nested query for filter. * * @param QueryBuilder $query * @param array $ids * * @return void */ protected function initNestedQuery(QueryBuilder $query, array $ids) { $connection = $query->getConnection(); $keyName = $connection->raw($this->relation->getParent()->getQualifiedKeyName()); $query->from($this->relation->getTable())->select($connection->raw('1'))->where($this->relation->getForeignKey(), '=', $keyName)->whereIn($this->relation->getOtherKey(), $ids); }
/** * Create instance * * @param VirtualConnectionInterface $connector connector * @param string $table table name * @param bool $dynamic proxy use or disuse */ public function __construct(VirtualConnectionInterface $connector, $table, $dynamic = false) { /** * \Illuminate\Database\Query\Builder 를 만들기 위해서 connection 이 필요하다. * Builder 를 미리 생성해야 하는 이슈 때문에 driver 를 혼합해서 사용 할 수 없다. * mysql, mssql 을 같이 사용 할 수 없음. * default connection 으로 사용되는 driver 만 설정이 가능함. */ /** * @param Connection $defaultConnection */ $defaultConnection = $connector->getDefaultConnection(); $processor = $defaultConnection->getPostProcessor(); $query = new Builder($connector, $defaultConnection->getQueryGrammar(), $processor); $query->from($table); $this->connector = $connector; $this->query = $query; $this->table = $table; $this->dynamic = $dynamic; }