|
11 | 11 | use Yiisoft\Db\Exception\InvalidCallException; |
12 | 12 | use Yiisoft\Db\Exception\InvalidConfigException; |
13 | 13 | use Yiisoft\Db\Exception\NotSupportedException; |
| 14 | +use Yiisoft\Db\Expression\ExpressionInterface; |
14 | 15 | use Yiisoft\Db\Query\BatchQueryResultInterface; |
15 | 16 | use Yiisoft\Db\Query\QueryInterface; |
| 17 | +use Yiisoft\Db\Query\QueryPartsInterface; |
16 | 18 | use Yiisoft\Db\QueryBuilder\QueryBuilderInterface; |
17 | 19 | use Yiisoft\Db\Schema\Column\ColumnFactoryInterface; |
18 | 20 | use Yiisoft\Db\Schema\QuoterInterface; |
|
28 | 30 | * different database systems without having to worry about the specific details of each one. |
29 | 31 | * |
30 | 32 | * @psalm-type ParamsType = array<non-empty-string, mixed>|list<mixed> |
| 33 | + * @psalm-import-type SelectValue from QueryPartsInterface |
31 | 34 | */ |
32 | 35 | interface ConnectionInterface |
33 | 36 | { |
@@ -71,6 +74,13 @@ public function createBatchQueryResult(QueryInterface $query): BatchQueryResultI |
71 | 74 | */ |
72 | 75 | public function createCommand(?string $sql = null, array $params = []): CommandInterface; |
73 | 76 |
|
| 77 | + /** |
| 78 | + * Creates a query instance. |
| 79 | + * |
| 80 | + * @return QueryInterface The query instance. |
| 81 | + */ |
| 82 | + public function createQuery(): QueryInterface; |
| 83 | + |
74 | 84 | /** |
75 | 85 | * Create a transaction instance. |
76 | 86 | * |
@@ -203,6 +213,30 @@ public function quoteValue(mixed $value): mixed; |
203 | 213 | */ |
204 | 214 | public function setEnableSavepoint(bool $value): void; |
205 | 215 |
|
| 216 | + /** |
| 217 | + * Creates a new {@see Query} instance with the specified columns to be selected. |
| 218 | + * |
| 219 | + * @param array|ExpressionInterface|scalar $columns The columns to be selected. |
| 220 | + * Columns can be specified in either a string (for example `id, name`) or an array (such as `['id', 'name']`). |
| 221 | + * Columns can be prefixed with table names (such as `user.id`) and/or contain column aliases |
| 222 | + * (for example `user.id AS user_id`). |
| 223 | + * The method will automatically quote the column names unless a column has some parenthesis (which means the |
| 224 | + * column has a DB expression). |
| 225 | + * A DB expression may also be passed in form of an {@see ExpressionInterface} object. |
| 226 | + * Note that if you are selecting an expression like `CONCAT(first_name, ' ', last_name)`, you should use an array |
| 227 | + * to specify the columns. Otherwise, the expression may be incorrectly split into several parts. |
| 228 | + * When the columns are specified as an array, you may also use array keys as the column aliases (if a column |
| 229 | + * doesn't need alias, don't use a string key). |
| 230 | + * @param string|null $option More option that should be appended to the 'SELECT' keyword. For example, in MySQL, |
| 231 | + * the option 'SQL_CALC_FOUND_ROWS' can be used. |
| 232 | + * |
| 233 | + * @psalm-param SelectValue|scalar|ExpressionInterface $columns |
| 234 | + */ |
| 235 | + public function select( |
| 236 | + array|bool|float|int|string|ExpressionInterface $columns = [], |
| 237 | + ?string $option = null, |
| 238 | + ): QueryInterface; |
| 239 | + |
206 | 240 | /** |
207 | 241 | * The common prefix or suffix for table names. |
208 | 242 | * If a table name is `{{%TableName}}`, then the percentage |
|
0 commit comments