Upgrade to 4.0.0

This commit is contained in:
Bastian Allgeier
2023-11-28 09:33:56 +01:00
parent f96b96af76
commit 3b0b6546ca
480 changed files with 21371 additions and 13327 deletions

View File

@@ -3,6 +3,8 @@
namespace Kirby\Database;
use Closure;
use Kirby\Database\Sql\Mysql;
use Kirby\Database\Sql\Sqlite;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Toolkit\A;
use Kirby\Toolkit\Collection;
@@ -536,7 +538,7 @@ class Database
* MySQL database connector
*/
Database::$types['mysql'] = [
'sql' => 'Kirby\Database\Sql\Mysql',
'sql' => Mysql::class,
'dsn' => function (array $params): string {
if (isset($params['host']) === false && isset($params['socket']) === false) {
throw new InvalidArgumentException('The mysql connection requires either a "host" or a "socket" parameter');
@@ -574,7 +576,7 @@ Database::$types['mysql'] = [
* SQLite database connector
*/
Database::$types['sqlite'] = [
'sql' => 'Kirby\Database\Sql\Sqlite',
'sql' => Sqlite::class,
'dsn' => function (array $params): string {
if (isset($params['database']) === false) {
throw new InvalidArgumentException('The sqlite connection requires a "database" parameter');

View File

@@ -191,7 +191,7 @@ Db::$queries['column'] = function (
* @param array $values An array of values which should be inserted
* @return mixed Returns the last inserted id on success or false
*/
Db::$queries['insert'] = function (string $table, array $values) {
Db::$queries['insert'] = function (string $table, array $values): mixed {
return Db::table($table)->insert($values);
};
@@ -225,9 +225,8 @@ Db::$queries['delete'] = function (string $table, $where = null): bool {
*
* @param string $table The name of the table which should be queried
* @param mixed $where An optional WHERE clause
* @return int
*/
Db::$queries['count'] = function (string $table, $where = null): int {
Db::$queries['count'] = function (string $table, mixed $where = null): int {
return Db::table($table)->where($where)->count();
};

View File

@@ -259,8 +259,11 @@ class Query
* @param string $type The join type. Uses an inner join by default
* @return $this
*/
public function join(string $table, string $on, string $type = 'JOIN'): static
{
public function join(
string $table,
string $on,
string $type = 'JOIN'
): static {
$join = [
'table' => $table,
'on' => $on,
@@ -678,7 +681,7 @@ class Query
$collection = $this
->offset($pagination->offset())
->limit($pagination->limit())
->iterator('Kirby\Toolkit\Collection')
->iterator(Collection::class)
->all();
$this->iterator($iterator);

View File

@@ -144,7 +144,7 @@ abstract class Sql
* Combines an identifier (table and column)
*
* @param $values bool Whether the identifier is going to be used for a VALUES clause;
* only relevant for SQLite
* only relevant for SQLite
*/
public function combineIdentifier(string $table, string $column, bool $values = false): string
{