From 7627fa1e2e01aaca67eddc961bad4574a0a15784 Mon Sep 17 00:00:00 2001 From: gtbu Date: Sat, 11 Jun 2022 11:21:45 +0200 Subject: [PATCH] Medoo update 2.1.6 --- include/thirdparty/db/Medoo.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/include/thirdparty/db/Medoo.php b/include/thirdparty/db/Medoo.php index bfc864b..00cdb44 100644 --- a/include/thirdparty/db/Medoo.php +++ b/include/thirdparty/db/Medoo.php @@ -6,10 +6,10 @@ declare(strict_types=1); * * The Lightweight PHP Database Framework to Accelerate Development. * - * @version 2.1.3 + * @version 2.1.6 * @author Angel Lai * @package Medoo - * @copyright Copyright 2021 Medoo Project, Angel Lai. + * @copyright Copyright 2022 Medoo Project, Angel Lai. * @license https://opensource.org/licenses/MIT * @link https://medoo.in */ @@ -105,7 +105,7 @@ class Medoo protected $logs = []; /** - * Determine should log or not. + * Determine should log the query or not. * * @var bool */ @@ -119,7 +119,7 @@ class Medoo protected $testMode = false; /** - * The query string last generated in test mode. + * The last query string was generated in test mode. * * @var string */ @@ -133,7 +133,7 @@ class Medoo protected $debugMode = false; /** - * Determine should saving debug logging. + * Determine should save debug logging. * * @var bool */ @@ -478,7 +478,7 @@ class Medoo } /** - * Generate a new map key for placeholder. + * Generate a new map key for the placeholder. * * @return string */ @@ -659,7 +659,7 @@ class Medoo } $query = preg_replace_callback( - '/(([`\']).*?)?((FROM|TABLE|INTO|UPDATE|JOIN)\s*)?\<(([\p{L}_][\p{L}\p{N}@$#\-_]*)(\.[\p{L}_][\p{L}\p{N}@$#\-_]*)?)\>([^,]*?\2)?/u', + '/(([`\']).*?)?((FROM|TABLE|INTO|UPDATE|JOIN|TABLE IF EXISTS)\s*)?\<(([\p{L}_][\p{L}\p{N}@$#\-_]*)(\.[\p{L}_][\p{L}\p{N}@$#\-_]*)?)\>([^,]*?\2)?/u', function ($matches) { if (!empty($matches[2]) && isset($matches[8])) { return $matches[0]; @@ -830,7 +830,7 @@ class Medoo } /** - * Implode where conditions. + * Implode the Where conditions. * * @param array $data * @param array $map @@ -856,7 +856,7 @@ class Medoo $isIndex = is_int($key); preg_match( - '/([\p{L}_][\p{L}\p{N}@$#\-_\.]*)(\[(?\>\=?|\<\=?|\=|\!\=?|\<\>|\>\<|\!?~|REGEXP)\])?([\p{L}_][\p{L}\p{N}@$#\-_\.]*)?/u', + '/([\p{L}_][\p{L}\p{N}@$#\-_\.]*)(\[(?.*)\])?([\p{L}_][\p{L}\p{N}@$#\-_\.]*)?/u', $isIndex ? $value : $key, $match ); @@ -869,7 +869,7 @@ class Medoo continue; } - if ($operator) { + if ($operator && $operator != '=') { if (in_array($operator, ['>', '>=', '<', '<='])) { $condition = "{$column} {$operator} "; @@ -965,6 +965,8 @@ class Medoo } elseif ($operator === 'REGEXP') { $stack[] = "{$column} REGEXP {$mapKey}"; $map[$mapKey] = [$value, PDO::PARAM_STR]; + } else { + throw new InvalidArgumentException("Invalid operator [{$operator}] for column {$column} supplied."); } continue; @@ -1165,7 +1167,7 @@ class Medoo array &$map, $join, &$columns = null, - array $where = null, + $where = null, $columnFn = null ): string { preg_match('/(?[\p{L}_][\p{L}\p{N}@$#\-_]*)\s*\((?[\p{L}_][\p{L}\p{N}@$#\-_]*)\)/u', $table, $tableMatch); @@ -1226,10 +1228,10 @@ class Medoo } /** - * Determine the array is with join syntax. + * Determine the array with join syntax. * * @param mixed $join - * @return string + * @return bool */ protected function isJoin($join): bool { @@ -1562,7 +1564,7 @@ class Medoo */ public function drop(string $table): ?PDOStatement { - return $this->exec('DROP TABLE IF EXISTS ' . $this->tableQuote($this->prefix . $table)); + return $this->exec('DROP TABLE IF EXISTS ' . $this->tableQuote($table)); } /**