Upgrade to 3.6.0

This commit is contained in:
Bastian Allgeier
2021-11-16 14:53:37 +01:00
parent 7388fa4d24
commit 92b7a330fa
318 changed files with 20017 additions and 6878 deletions

View File

@@ -205,7 +205,7 @@ class Database
}
// fetch the dsn and store it
$this->dsn = static::$types[$this->type]['dsn']($options);
$this->dsn = (static::$types[$this->type]['dsn'])($options);
// try to connect
$this->connection = new PDO($this->dsn, $options['user'], $options['password']);
@@ -504,7 +504,7 @@ class Database
{
if ($this->tables === null) {
// Get the list of tables from the database
$sql = $this->sql()->tables($this->database);
$sql = $this->sql()->tables();
$results = $this->query($sql['query'], $sql['bindings']);
if ($results) {

View File

@@ -123,7 +123,7 @@ class Db
public static function __callStatic(string $method, $arguments)
{
if (isset(static::$queries[$method])) {
return static::$queries[$method](...$arguments);
return (static::$queries[$method])(...$arguments);
}
if (static::$connection !== null && method_exists(static::$connection, $method) === true) {
@@ -134,9 +134,10 @@ class Db
}
}
// @codeCoverageIgnoreStart
/**
* Shortcut for SELECT clauses
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param mixed $columns Either a string with columns or an array of column names
@@ -152,7 +153,6 @@ Db::$queries['select'] = function (string $table, $columns = '*', $where = null,
/**
* Shortcut for selecting a single row in a table
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param mixed $columns Either a string with columns or an array of column names
@@ -168,7 +168,6 @@ Db::$queries['first'] = Db::$queries['row'] = Db::$queries['one'] = function (st
/**
* Returns only values from a single column
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param string $column The name of the column to select from
@@ -184,19 +183,17 @@ Db::$queries['column'] = function (string $table, string $column, $where = null,
/**
* Shortcut for inserting a new row into a table
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param array $values An array of values which should be inserted
* @return int ID of the inserted row
* @return mixed Returns the last inserted id on success or false
*/
Db::$queries['insert'] = function (string $table, array $values): int {
Db::$queries['insert'] = function (string $table, array $values) {
return Db::table($table)->insert($values);
};
/**
* Shortcut for updating a row in a table
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param array $values An array of values which should be inserted
@@ -209,7 +206,6 @@ Db::$queries['update'] = function (string $table, array $values, $where = null):
/**
* Shortcut for deleting rows in a table
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param mixed $where An optional WHERE clause
@@ -221,7 +217,6 @@ Db::$queries['delete'] = function (string $table, $where = null): bool {
/**
* Shortcut for counting rows in a table
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param mixed $where An optional WHERE clause
@@ -233,7 +228,6 @@ Db::$queries['count'] = function (string $table, $where = null): int {
/**
* Shortcut for calculating the minimum value in a column
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param string $column The name of the column of which the minimum should be calculated
@@ -246,7 +240,6 @@ Db::$queries['min'] = function (string $table, string $column, $where = null): f
/**
* Shortcut for calculating the maximum value in a column
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param string $column The name of the column of which the maximum should be calculated
@@ -259,7 +252,6 @@ Db::$queries['max'] = function (string $table, string $column, $where = null): f
/**
* Shortcut for calculating the average value in a column
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param string $column The name of the column of which the average should be calculated
@@ -272,7 +264,6 @@ Db::$queries['avg'] = function (string $table, string $column, $where = null): f
/**
* Shortcut for calculating the sum of all values in a column
* @codeCoverageIgnore
*
* @param string $table The name of the table which should be queried
* @param string $column The name of the column of which the sum should be calculated
@@ -282,3 +273,5 @@ Db::$queries['avg'] = function (string $table, string $column, $where = null): f
Db::$queries['sum'] = function (string $table, string $column, $where = null): float {
return Db::table($table)->where($where)->sum($column);
};
// @codeCoverageIgnoreEnd

View File

@@ -341,7 +341,7 @@ class Query
*/
public function innerJoin($table, $on)
{
return $this->join($table, $on, 'inner');
return $this->join($table, $on, 'inner join');
}
/**
@@ -710,7 +710,7 @@ class Query
$this->database->fail();
}
$result = $this->database->execute($sql['query'], $sql['bindings'], $params);
$result = $this->database->execute($sql['query'], $sql['bindings']);
$this->reset();
@@ -1009,9 +1009,8 @@ class Query
$key = $sql->columnName($this->table, $args[0]);
// ->where('username', 'in', ['myuser', 'myotheruser']);
$predicate = trim(strtoupper($args[1]));
if (is_array($args[2]) === true) {
$predicate = trim(strtoupper($args[1]));
if (in_array($predicate, ['IN', 'NOT IN']) === false) {
throw new InvalidArgumentException('Invalid predicate ' . $predicate);
}
@@ -1029,11 +1028,8 @@ class Query
// add that to the where clause in parenthesis
$result = $key . ' ' . $predicate . ' (' . implode(', ', $values) . ')';
$this->bindings($bindings);
// ->where('username', 'like', 'myuser');
} else {
$predicate = trim(strtoupper($args[1]));
$predicates = [
'=', '>=', '>', '<=', '<', '<>', '!=', '<=>',
'IS', 'IS NOT',
@@ -1051,9 +1047,8 @@ class Query
$bindings[$valueBinding] = $args[2];
$result = $key . ' ' . $predicate . ' ' . $valueBinding;
$this->bindings($bindings);
}
$this->bindings($bindings);
}
break;

View File

@@ -225,7 +225,7 @@ abstract class Sql
'null' => $null,
'default' => $columnDefault['query'],
'unique' => $uniqueColumn
], ''));
], ['fallback' => '']));
return [
'query' => $query,