catfan / Medoo

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

Error when using Raw with IN #1079

Closed ggedde closed 7 months ago

ggedde commented 1 year ago

Medoo: 2.1.8 PHP: 8.1 Database: MySql System: Mac and Linux

Describe the Problem I am looking for a way to use Raw with the IN statement when using arrays. However when I do so I am get an Error: "PHP Fatal Error: Uncaught Error: Object of class Medoo\Raw could not be converted to string Medoo.php:556"

Detail Code Here is an example of my code

$data = $database->select('user', [
    'id',
    'name',
], [
    'id' => [
        Medoo::raw("uuid_to_bin('d9fca370-319b-4529-a15c-0d27d9053ef1')"),
        Medoo::raw("uuid_to_bin('9b629b8c-c1a2-4b7d-aa4b-3d6fa85ca85a')"),
    ]
]);

Expected output I would expect it to work the same way as using Raw for a single value. As this works.

$data = $database->select('user', [
    'id',
    'name',
], [
    'id' => Medoo::raw("uuid_to_bin('d9fca370-319b-4529-a15c-0d27d9053ef1')")
]);

Or is there another way to do what I am trying to do. Thanks

receiver1 commented 1 year ago

This is really a much needed change. Because now you have to completely replace WHERE with Medoo::raw to do this.