Skip to content

Commit c761ccb

Browse files
authored
Fixes (#675)
1 parent 0a74d2d commit c761ccb

15 files changed

Lines changed: 102 additions & 111 deletions

src/Command/CommandInterface.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ public function addPrimaryKey(string $table, string $name, array|string $columns
138138
/**
139139
* Creates an SQL command for changing the definition of a column.
140140
*
141-
* @param string $table The table whose column is to be changed.
142-
* @param string $column The name of the column to be changed.
141+
* @param string $table The table whose column is to change.
142+
* @param string $column The name of the column to change.
143143
* @param string $type The column type. {@see QueryBuilder::getColumnType()} will be called to convert the give
144144
* column type to the physical one. For example, `string` will be converted as `varchar(255)`, and `string not null`
145145
* becomes `varchar(255) not null`.
@@ -165,15 +165,15 @@ public function alterColumn(string $table, string $column, string $type): static
165165
* )->execute();
166166
* ```
167167
*
168-
* The method will escape the column names, and quote the values to be inserted.
168+
* The method will escape the column names, and quote the values to insert.
169169
*
170170
* Note that the values in each row must match the corresponding column names.
171171
*
172172
* Also note that the created command isn't executed until {@see execute()} is called.
173173
*
174-
* @param string $table The table that new rows will be inserted into.
174+
* @param string $table The name of the table to insert new rows into.
175175
* @param array $columns The column names.
176-
* @param iterable $rows The rows to be batched inserted into the table.
176+
* @param iterable $rows The rows to be batch inserted into the table.
177177
*
178178
* @throws Exception
179179
* @throws InvalidArgumentException
@@ -189,7 +189,7 @@ public function batchInsert(string $table, array $columns, iterable $rows): stat
189189
* a parameter name of the form `:name`. For a prepared statement using question mark placeholders, this will be the
190190
* 1-indexed position of the parameter.
191191
* @param mixed $value The PHP variable to bind to the SQL statement parameter (passed by reference).
192-
* @param int|null $dataType The SQL data type of the parameter. If null, the type is determined by the PHP type of
192+
* @param int|null $dataType The SQL data type of the parameter. If `null`, the type is determined by the PHP type of
193193
* the value.
194194
* @param int|null $length The length of the data type.
195195
* @param mixed|null $driverOptions The driver-specific options.
@@ -212,7 +212,7 @@ public function bindParam(
212212
* @param string $table The name of the table to add unique constraint to.
213213
* @param string $name The name of the unique constraint.
214214
* @param array|string $columns The name of the column to add unique constraint to. If there are
215-
* many columns, separate them with commas.
215+
* many columns, use an array or separate them with commas.
216216
*
217217
* Note: The method will quote the `name`, `table`, and `column` parameters before using them in the generated SQL.
218218
*/
@@ -237,7 +237,7 @@ public function bindValue(int|string $name, mixed $value, int $dataType = null):
237237
*
238238
* Note that the SQL data type of each value is determined by its PHP type.
239239
*
240-
* @param array|ParamInterface[] $values The values to be bound. This must be given in terms of an associative
240+
* @param array|ParamInterface[] $values The values to bind. This must be given in terms of an associative
241241
* array with array keys being the parameter names, and an array values the corresponding parameter values,
242242
* for example, `[':name' => 'John', ':age' => 25]`.
243243
* By default, the {@see PDO} type of each value is determined by its PHP type. You may explicitly specify the
@@ -302,7 +302,7 @@ public function createIndex(
302302
* For example, it will convert `string` to `varchar(255)`, and `string not null` to
303303
* `varchar(255) not null`.
304304
*
305-
* If you specify a column with definition only ('PRIMARY KEY (name, type)'), it will be directly inserted
305+
* If you specify a column with definition only (`PRIMARY KEY (name, type)`), it will be directly inserted
306306
* into the generated SQL.
307307
*
308308
* @param string $table The name of the table to create.

src/Connection/ConnectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function isSavepointEnabled(): bool;
179179
* It does nothing if a DB connection is active.
180180
*
181181
* @throws Exception If connection fails.
182-
* @throws InvalidConfigException If connection can not be established because of incomplete configuration.
182+
* @throws InvalidConfigException If a connection can't be established because of incomplete configuration.
183183
*/
184184
public function open(): void;
185185

src/Query/Query.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function addSelect(array|string|ExpressionInterface $columns): static
193193
return $this;
194194
}
195195

196-
public function andFilterCompare(string $name, string|null $value, string $defaultOperator = '='): static
196+
public function andFilterCompare(string $column, string|null $value, string $defaultOperator = '='): static
197197
{
198198
$operator = $defaultOperator;
199199

@@ -202,7 +202,7 @@ public function andFilterCompare(string $name, string|null $value, string $defau
202202
$value = substr((string) $value, strlen($operator));
203203
}
204204

205-
return $this->andFilterWhere([$operator, $name, $value]);
205+
return $this->andFilterWhere([$operator, $column, $value]);
206206
}
207207

208208
public function andWhere($condition, array $params = []): static
@@ -229,11 +229,11 @@ public function all(): array
229229
return DbArrayHelper::populate($this->createCommand()->queryAll(), $this->indexBy);
230230
}
231231

232-
public function average(string $q): int|float|null|string
232+
public function average(string $sql): int|float|null|string
233233
{
234234
return match ($this->emulateExecution) {
235235
true => null,
236-
false => is_numeric($avg = $this->queryScalar("AVG($q)")) ? $avg : null,
236+
false => is_numeric($avg = $this->queryScalar("AVG($sql)")) ? $avg : null,
237237
};
238238
}
239239

@@ -291,11 +291,11 @@ public function column(): array
291291
return $results;
292292
}
293293

294-
public function count(string $q = '*'): int|string
294+
public function count(string $sql = '*'): int|string
295295
{
296296
return match ($this->emulateExecution) {
297297
true => 0,
298-
false => is_numeric($count = $this->queryScalar("COUNT($q)")) ? (int) $count : 0,
298+
false => is_numeric($count = $this->queryScalar("COUNT($sql)")) ? (int) $count : 0,
299299
};
300300
}
301301

@@ -506,15 +506,15 @@ public function limit(ExpressionInterface|int|null $limit): static
506506
return $this;
507507
}
508508

509-
public function max(string $q): int|float|null|string
509+
public function max(string $sql): int|float|null|string
510510
{
511-
$max = $this->queryScalar("MAX($q)");
511+
$max = $this->queryScalar("MAX($sql)");
512512
return is_numeric($max) ? $max : null;
513513
}
514514

515-
public function min(string $q): int|float|null|string
515+
public function min(string $sql): int|float|null|string
516516
{
517-
$min = $this->queryScalar("MIN($q)");
517+
$min = $this->queryScalar("MIN($sql)");
518518
return is_numeric($min) ? $min : null;
519519
}
520520

@@ -641,11 +641,11 @@ public function shouldEmulateExecution(): bool
641641
return $this->emulateExecution;
642642
}
643643

644-
public function sum(string $q): int|float|null|string
644+
public function sum(string $sql): int|float|null|string
645645
{
646646
return match ($this->emulateExecution) {
647647
true => null,
648-
false => is_numeric($sum = $this->queryScalar("SUM($q)")) ? $sum : null,
648+
false => is_numeric($sum = $this->queryScalar("SUM($sql)")) ? $sum : null,
649649
};
650650
}
651651

src/Query/QueryFunctionsInterface.php

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,74 +19,69 @@ interface QueryFunctionsInterface
1919
/**
2020
* Returns the average of the specified column values.
2121
*
22-
* @param string $q The column name or expression.
22+
* @param string $sql The column name or expression.
2323
*
2424
* @throws Throwable
25-
*
2625
* @return float|int|string|null The average of the specified column values.
2726
*
2827
* Note: Make sure you quote column names in the expression.
2928
*/
30-
public function average(string $q): int|float|null|string;
29+
public function average(string $sql): int|float|null|string;
3130

3231
/**
3332
* Returns the number of records.
3433
*
35-
* @param string $q The `COUNT` expression. Defaults to '*'.
34+
* @param string $sql The `COUNT` expression. Defaults to '*'.
3635
*
37-
* @throws Exception
3836
* @throws InvalidConfigException
3937
* @throws Throwable
40-
*
38+
* @throws Exception
4139
* @return int|string Number of records. The result may be a string depending on the underlying database engine and
4240
* to support integer values higher than a 32bit PHP integer can handle.
4341
*
4442
* Note: Make sure you quote column names in the expression.
4543
*/
46-
public function count(string $q = '*'): int|string;
44+
public function count(string $sql = '*'): int|string;
4745

4846
/**
4947
* Returns the maximum of the specified column values.
5048
*
51-
* @param string $q The column name or expression.
49+
* @param string $sql The column name or expression.
5250
*
53-
* @throws Exception
5451
* @throws InvalidConfigException
5552
* @throws Throwable
56-
*
53+
* @throws Exception
5754
* @return float|int|string|null The maximum of the specified column values.
5855
*
5956
* Note: Make sure you quote column names in the expression.
6057
*/
61-
public function max(string $q): int|float|null|string;
58+
public function max(string $sql): int|float|null|string;
6259

6360
/**
6461
* Returns the minimum of the specified column values.
6562
*
66-
* @param string $q The column name or expression.
63+
* @param string $sql The column name or expression.
6764
*
68-
* @throws Exception
6965
* @throws InvalidConfigException
7066
* @throws Throwable
71-
*
67+
* @throws Exception
7268
* @return float|int|string|null The minimum of the specified column values.
7369
*
7470
* Note: Make sure you quote column names in the expression.
7571
*/
76-
public function min(string $q): int|float|null|string;
72+
public function min(string $sql): int|float|null|string;
7773

7874
/**
7975
* Returns the sum of the specified column values.
8076
*
81-
* @param string $q The column name or expression.
77+
* @param string $sql The column name or expression.
8278
*
83-
* @throws Exception
8479
* @throws InvalidConfigException
8580
* @throws Throwable
86-
*
81+
* @throws Exception
8782
* @return float|int|string|null The sum of the specified column values.
8883
*
8984
* Note: Make sure you quote column names in the expression.
9085
*/
91-
public function sum(string $q): int|float|null|string;
86+
public function sum(string $sql): int|float|null|string;
9287
}

src/Query/QueryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
interface QueryInterface extends ExpressionInterface, QueryPartsInterface, QueryFunctionsInterface
3030
{
3131
/**
32-
* Adds more parameters to biun to the query.
32+
* Adds more parameters to bind to the query.
3333
*
3434
* @param array $params The list of query parameter values indexed by parameter placeholders.
3535
* For example, `[':name' => 'Dan', ':age' => 31]`.

0 commit comments

Comments
 (0)