/** * Set where to fetch which columns * * This notifies the repository about each desired query column. * * @param mixed $target The target from which to fetch the columns * @param array $columns If null or an empty array, all columns will be fetched * * @return $this */ public function from($target, array $columns = null) { $target = $this->repository->requireTable($target, $this); $this->query = $this->repository->getDataSource()->select()->from($target); $this->query->columns($this->prepareQueryColumns($target, $columns)); $this->target = $target; return $this; }
/** * Validate that the requested table exists * * This will prepend the datasource's table prefix and will apply the table's alias, if any. * * @param string $table The table to validate * @param RepositoryQuery $query An optional query to pass as context * (unused by the base implementation) * * @return array|string * * @throws ProgrammingError In case the given table does not exist */ public function requireTable($table, RepositoryQuery $query = null) { $virtualTable = null; $statementColumns = $this->getStatementColumns(); if (!isset($statementColumns[$table])) { $newTable = parent::requireTable($table); if ($newTable !== $table) { $virtualTable = $table; } $table = $newTable; } return $this->prependTablePrefix($this->applyTableAlias($table, $virtualTable)); }
/** * Validate that the requested document type exists * * @param string|array $documentType The document type to validate * @param RepositoryQuery $query An optional query to pass as context * * @return array The document type with its index being applied */ public function requireTable($documentType, RepositoryQuery $query = null) { if ($query !== null) { $query->getQuery()->setIndices(array($this->getIndex())); } return parent::requireTable($this->extractDocumentType($documentType), $query); }