Update Meedo 2.1.12

This commit is contained in:
gtbu 2024-02-19 21:55:49 +01:00
parent aee10265f0
commit c9b79a5874
3 changed files with 2285 additions and 45 deletions

View file

@ -6,10 +6,10 @@ declare(strict_types=1);
*
* The Lightweight PHP Database Framework to Accelerate Development.
*
* @version 2.1.6
* @version 2.1.12
* @author Angel Lai
* @package Medoo
* @copyright Copyright 2022 Medoo Project, Angel Lai.
* @copyright Copyright 2024 Medoo Project, Angel Lai.
* @license https://opensource.org/licenses/MIT
* @link https://medoo.in
*/
@ -51,14 +51,14 @@ class Raw
* @method bool has(string $table, array $where)
* @method mixed rand(string $table, array|string $column, array $where)
* @method int count(string $table, array $where)
* @method int max(string $table, string $column)
* @method int min(string $table, string $column)
* @method int avg(string $table, string $column)
* @method int sum(string $table, string $column)
* @method int max(string $table, string $column, array $where)
* @method int min(string $table, string $column, array $where)
* @method int avg(string $table, string $column, array $where)
* @method int sum(string $table, string $column, array $where)
* @method string max(string $table, string $column)
* @method string min(string $table, string $column)
* @method string avg(string $table, string $column)
* @method string sum(string $table, string $column)
* @method string max(string $table, string $column, array $where)
* @method string min(string $table, string $column, array $where)
* @method string avg(string $table, string $column, array $where)
* @method string sum(string $table, string $column, array $where)
*/
class Medoo
{
@ -234,9 +234,7 @@ class Medoo
}
$option = $options['option'] ?? [];
$commands = (isset($options['command']) && is_array($options['command'])) ?
$options['command'] :
[];
$commands = [];
switch ($this->type) {
@ -469,6 +467,10 @@ class Medoo
);
}
if (isset($options['command']) && is_array($options['command'])) {
$commands = array_merge($commands, $options['command']);
}
foreach ($commands as $value) {
$this->pdo->exec($value);
}
@ -602,7 +604,7 @@ class Medoo
foreach ($map as $key => $value) {
if ($value[1] === PDO::PARAM_STR) {
$replace = $this->quote($value[0]);
$replace = $this->quote("{$value[0]}");
} elseif ($value[1] === PDO::PARAM_NULL) {
$replace = 'NULL';
} elseif ($value[1] === PDO::PARAM_LOB) {
@ -659,7 +661,7 @@ class Medoo
}
$query = preg_replace_callback(
'/(([`\']).*?)?((FROM|TABLE|INTO|UPDATE|JOIN|TABLE IF EXISTS)\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)?/',
function ($matches) {
if (!empty($matches[2]) && isset($matches[8])) {
return $matches[0];
@ -865,7 +867,7 @@ class Medoo
$operator = $match['operator'] ?? null;
if ($isIndex && isset($match[4]) && in_array($operator, ['>', '>=', '<', '<=', '=', '!='])) {
$stack[] = "${column} ${operator} " . $this->columnQuote($match[4]);
$stack[] = "{$column} {$operator} " . $this->columnQuote($match[4]);
continue;
}
@ -892,15 +894,20 @@ class Medoo
break;
case 'array':
$placeholders = [];
$values = [];
foreach ($value as $index => $item) {
$stackKey = $mapKey . $index . '_i';
$placeholders[] = $stackKey;
$map[$stackKey] = $this->typeMap($item, gettype($item));
if ($raw = $this->buildRaw($item, $map)) {
$values[] = $raw;
} else {
$stackKey = $mapKey . $index . '_i';
$values[] = $stackKey;
$map[$stackKey] = $this->typeMap($item, gettype($item));
}
}
$stack[] = $column . ' NOT IN (' . implode(', ', $placeholders) . ')';
$stack[] = $column . ' NOT IN (' . implode(', ', $values) . ')';
break;
case 'object':
@ -935,14 +942,15 @@ class Medoo
$likeClauses = [];
foreach ($value as $index => $item) {
$likeKey = "{$mapKey}_{$index}_i";
$item = strval($item);
if (!preg_match('/((?<!\\\)\[.+(?<!\\\)\]|(?<!\\\)[\*\?\!\%#^_]|%.+|.+%)/', $item)) {
$item = '%' . $item . '%';
}
$likeClauses[] = $column . ($operator === '!~' ? ' NOT' : '') . " LIKE {$mapKey}L{$index}";
$map["{$mapKey}L{$index}"] = [$item, PDO::PARAM_STR];
$likeClauses[] = $column . ($operator === '!~' ? ' NOT' : '') . " LIKE {$likeKey}";
$map[$likeKey] = [$item, PDO::PARAM_STR];
}
$stack[] = '(' . implode($connector, $likeClauses) . ')';
@ -979,16 +987,20 @@ class Medoo
break;
case 'array':
$placeholders = [];
$values = [];
foreach ($value as $index => $item) {
$stackKey = $mapKey . $index . '_i';
if ($raw = $this->buildRaw($item, $map)) {
$values[] = $raw;
} else {
$stackKey = $mapKey . $index . '_i';
$placeholders[] = $stackKey;
$map[$stackKey] = $this->typeMap($item, gettype($item));
$values[] = $stackKey;
$map[$stackKey] = $this->typeMap($item, gettype($item));
}
}
$stack[] = $column . ' IN (' . implode(', ', $placeholders) . ')';
$stack[] = $column . ' IN (' . implode(', ', $values) . ')';
break;
case 'object':
@ -1316,7 +1328,7 @@ class Medoo
$tableName .= ' AS ' . $this->tableQuote($match['alias']);
}
$tableJoin[] = $type[$match['join']] . " JOIN ${tableName} ${relation}";
$tableJoin[] = $type[$match['join']] . " JOIN {$tableName} {$relation}";
}
return implode(' ', $tableJoin);
@ -1346,14 +1358,14 @@ class Medoo
$stack[$value] = isset($keyMatch['type']) ?
[$columnKey, $keyMatch['type']] :
[$columnKey, 'String'];
[$columnKey];
} elseif ($this->isRaw($value)) {
preg_match('/([\p{L}_][\p{L}\p{N}@$#\-_]*\.)?(?<column>[\p{L}_][\p{L}\p{N}@$#\-_]*)(\s*\[(?<type>(String|Bool|Int|Number))\])?/u', $key, $keyMatch);
$columnKey = $keyMatch['column'];
$stack[$key] = isset($keyMatch['type']) ?
[$columnKey, $keyMatch['type']] :
[$columnKey, 'String'];
[$columnKey];
} elseif (!is_int($key) && is_array($value)) {
if ($root && count(array_keys($columns)) === 1) {
$stack[$key] = [$key, 'String'];
@ -1459,7 +1471,7 @@ class Medoo
break;
case 'String':
$stack[$columnKey] = $item;
$stack[$columnKey] = (string) $item;
break;
}
} else {
@ -2223,7 +2235,11 @@ class Medoo
];
foreach ($output as $key => $value) {
$output[$key] = @$this->pdo->getAttribute(constant('PDO::ATTR_' . $value));
try {
$output[$key] = $this->pdo->getAttribute(constant('PDO::ATTR_' . $value));
} catch (PDOException $e) {
$output[$key] = $e->getMessage();
}
}
$output['dsn'] = $this->dsn;

2233
include/thirdparty/db/Medoo2.1.6.php vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,8 @@
<p align="center">
<a href="https://medoo.in" target="_blank"><img src="https://cloud.githubusercontent.com/assets/1467904/19835326/ca62bc36-9ebd-11e6-8b37-7240d76319cd.png"></a>
</p>
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img alt="Build Status" src="https://github.com/catfan/Medoo/actions/workflows/php.yml/badge.svg"></a>
<a href="https://packagist.org/packages/catfan/medoo"><img alt="Total Downloads" src="https://poser.pugx.org/catfan/medoo/downloads"></a>
<a href="https://packagist.org/packages/catfan/medoo"><img alt="Latest Stable Version" src="https://poser.pugx.org/catfan/medoo/v/stable"></a>
<a href="https://packagist.org/packages/catfan/medoo"><img alt="License" src="https://poser.pugx.org/catfan/medoo/license"></a>
<a href="https://opencollective.com/medoo"><img alt="Backers on Open Collective" src="https://opencollective.com/Medoo/backers/badge.svg"></a>
<a href="https://opencollective.com/medoo"><img alt="Sponsors on Open Collective" src="https://opencollective.com/Medoo/sponsors/badge.svg"> </a>
</p>
https://github.com/catfan/Medoo/tags - MIT - License
----------------------------------------------------------------
> The lightweight PHP database framework to accelerate development
The lightweight PHP database framework to accelerate development
## Features