以下查询应返回三行,但只返回一行:
$sql = $dbh->prepare("SELECT * FROM table_name WHERE state = ? AND id IN(?) AND status IN(?)");
$sql->execute(array(1, '1,2,3', '1,2,3'));
但是,没有绑定参数的同一查询作为IN()
函数的参数返回3行,因为它应该是:
$sql = $dbh->prepare("SELECT * FROM table_name WHERE state = ? AND id IN(1,2,3) AND status IN(1,2,3)");
$sql->execute(array(1));
为什么会发生这种情况,如何正确绑定1,2,3
作为IN()
的参数?