mirror of
https://codeberg.org/vlw/php-mysql.git
synced 2025-09-13 16:23:42 +02:00
fix: return types for executor methods (#29)
* fix: fix return types for executor methods * fix(doc): fix return types for executor methods in README
This commit is contained in:
parent
03235df47b
commit
4779b8b824
2 changed files with 7 additions and 7 deletions
|
@ -58,7 +58,7 @@ use libmysqldriver\MySQL;
|
|||
$db = new MySQL($host, $user, $pass, $db);
|
||||
```
|
||||
|
||||
All executor methods [`select()`](#select), [`update()`](#update), and [`insert()`](#insert) will return a [`mysqli_result`](https://www.php.net/manual/en/class.mysqli-result.php) object.
|
||||
All executor methods [`select()`](#select), [`update()`](#update), and [`insert()`](#insert) will return a [`mysqli_result`](https://www.php.net/manual/en/class.mysqli-result.php) object or boolean.
|
||||
|
||||
# SELECT
|
||||
|
||||
|
@ -69,7 +69,7 @@ Pass an associative array of strings, CSV string, or null to this method to filt
|
|||
```php
|
||||
$db->select(
|
||||
array|string|null $columns
|
||||
): mysqli_result;
|
||||
): mysqli_result|bool;
|
||||
```
|
||||
|
||||
In most cases you probably want to select with a constraint. Chain the [`where()`](#where) method before `select()` to filter the query
|
||||
|
@ -119,7 +119,7 @@ Use `MySQL->insert()` to append a new row to a database table
|
|||
$db->insert(
|
||||
// Array of values to INSERT
|
||||
array $values
|
||||
): mysqli_result
|
||||
): mysqli_result|bool
|
||||
// Returns true if row was inserted
|
||||
```
|
||||
|
||||
|
@ -146,7 +146,7 @@ Modify existing rows with `MySQL->update()`
|
|||
$db->get(
|
||||
// Key, value array of column names and values to update
|
||||
array $fields,
|
||||
): mysqli_result;
|
||||
): mysqli_result|bool;
|
||||
// Returns true if at least 1 row was changed
|
||||
```
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
*/
|
||||
|
||||
// Create Prepared Statament for SELECT with optional WHERE filters
|
||||
public function select(array|string|null $columns = null): mysqli_result {
|
||||
public function select(array|string|null $columns = null): mysqli_result|bool {
|
||||
$this->throw_if_no_table();
|
||||
|
||||
// Create array of columns from CSV
|
||||
|
@ -216,7 +216,7 @@
|
|||
}
|
||||
|
||||
// Create Prepared Statement for UPDATE using PRIMARY KEY as anchor
|
||||
public function update(array $entity): mysqli_result {
|
||||
public function update(array $entity): mysqli_result|bool {
|
||||
$this->throw_if_no_table();
|
||||
|
||||
// Make constraint for table model if defined
|
||||
|
@ -250,7 +250,7 @@
|
|||
}
|
||||
|
||||
// Create Prepared Statemt for INSERT
|
||||
public function insert(array $values): mysqli_result {
|
||||
public function insert(array $values): mysqli_result|bool {
|
||||
$this->throw_if_no_table();
|
||||
|
||||
// A value for each column in table model must be provided
|
||||
|
|
Loading…
Add table
Reference in a new issue