params['from'] ?? null; } /** * Get SELECT items. * * @return SelectExpression[] */ public function getSelect(): array { return array_map( function ($item) { if (is_array($item) && count($item)) { return SelectExpr::fromString($item[0]) ->withAlias($item[1] ?? null); } if (is_string($item)) { return SelectExpr::fromString($item); } throw new RuntimeException("Bad select item."); }, $this->params['select'] ?? [] ); } /** * Get ORDER items. */ public function getOrder(): array { return $this->params['orderBy'] ?? []; } /** * Whether DISTINCT is applied. */ public function isDistinct(): bool { return $this->params['distinct'] ?? false; } /** * Get GROUP BY items. */ public function getGroupBy(): array { return $this->params['orderBy'] ?? []; } /** * Get WHERE clause. */ public function getWhere(): ?WhereClause { $whereClause = $this->params['whereClause'] ?? null; if ($whereClause === null || $whereClause === []) { return null; } return WhereClause::fromRaw($whereClause); } private function validateRawParams(array $params): void { $this->validateRawParamsSelecting($params); if ( ( !empty($params['joins']) || !empty($params['leftJoins']) || !empty($params['whereClause']) || !empty($params['orderBy']) ) && empty($params['from']) && empty($params['fromQuery']) ) { throw new RuntimeException("Select params: Missing 'from'."); } } }