amphp / mysql

An async MySQL client for PHP, optimizing database interactions with efficient non-blocking capabilities. Perfect for responsive, high-performance applications.
Other
358 stars 63 forks source link

Substitue named parameter multiple times in a single query #90

Closed Bilge closed 5 years ago

Bilge commented 5 years ago

Currently parameter substitution for named parameters only works if the name is substituted exactly once per name. However, there seems to be no technical reason why the same name cannot or should not be used multiple times, and indeed, this is supported by PDO.

yield $this->connection->execute(
    'INSERT foo
        SET Alfa=:Alfa,
            Bravo=:Bravo,
            Charlie=:Bravo
        ON DUPLICATE KEY UPDATE
            Bravo=:Bravo,
            Charlie=:Bravo
    ',
    [
        'Alfa' => 1,
        'Bravo' => 2,
    ]
);

Notice: Undefined index: Bravo in ConnectionStatement.php line 130