lincanbin/PHP-PDO-MySQL-Class

about where in

Closed this issue · 3 comments

SELECT * FROM fruit WHERE name IN (apple','banana) AND color = 'red'
how to add "red" ?
$DB->query("SELECT * FROM fruit WHERE name IN (?) AND color = ? ",array('apple','banana'));

看来我设计时还是考虑不周。

@chainjoy, your query should be:

$DB->query("SELECT * FROM fruit WHERE name IN (?,?) AND color = ? ",array('apple','banana','red'));

In the latest version:

$DB->query("SELECT * FROM fruit WHERE name IN (:fruit) AND color = :color ",array(
    'fruit' => array('apple','banana'),
    'color' =>'red')
);