FaaPz / PDO

Just another PDO database library
MIT License
316 stars 103 forks source link

Between condition with parentheses lead to strange state #175

Open serge-kilimoff opened 2 years ago

serge-kilimoff commented 2 years ago

Hi,

When I write something like that :

        $db
            ->select()
            ->columns(['col1' => 'C1', 'col2' => 'C2'])
            ->from('table')
            ->where(new Grouping('AND', ...[
                new Conditional('C2', 'BETWEEN', ['2022-01-01', '2022-12-31']),
                new Conditional('C1', '=', 'OK'),
            ]));

the "between" clause is writing like that :

C2 BETWEEN ('2022-01-01' AND '2022-12-31') AND C1 = 'OK'

It's not working like expected because : https://dba.stackexchange.com/a/251542

(And I cannot passing array like second argument in Grouping, php raise an Exception. The doc seem to say "it's okay with an array")

For informations, i use php 7.2 and mariadb 10.3.

Thanks !

kwhat commented 2 years ago

Really? How bizarre. I need to look into this a little further but I will try to get this fixed next week.

Thanks for reporting!