catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

The log() method reports an error, there is a problem with type judgment 'double' => PDO::PARAM_STR. #1108

Closed TimeIsGoOn closed 9 months ago

TimeIsGoOn commented 10 months ago

Information

Describe the Problem 执行log()方法报错

TypeError: Medoo\Medoo::quote(): Argument #1 ($string) must be of type string, float given, called in /www/webman/vendor/catfan/medoo/src/Medoo.php on line 607 and defined in /www/webman/vendor/catfan/medoo/src/Medoo.php:696 Stack trace: #0 /www/webman/vendor/catfan/medoo/src/Medoo.php(607): Medoo\Medoo->quote(555.1)

1 /www/webman/vendor/catfan/medoo/src/Medoo.php(2205): Medoo\Medoo->generate('UPDATE \"page\" S...', Array)

2 [internal function]: Medoo\Medoo->Medoo\{closure}(Array)

3 /www/webman/vendor/catfan/medoo/src/Medoo.php(2203): array_map(Object(Closure), Array)

4 /www/webman/app/wmapi/controller/PageController.php(215): Medoo\Medoo->log()

问题出在 https://github.com/catfan/Medoo/blob/eb1ad19d127bd358b9a44abc60166b4a2c19a988/src/Medoo.php#L749 image 这里 double 类型被看做了字符串,但是555.1不是字符串, 导致调用quote函数时参数类型检查错误

https://github.com/catfan/Medoo/blob/eb1ad19d127bd358b9a44abc60166b4a2c19a988/src/Medoo.php#L607

image

image

请看看这个如何修改,或者是在调用的时候,类型强制转换为 string

catfan commented 9 months ago

Fixed it on b409028.

1011

1020