如何将params多次绑定两次

时间:2018-05-18 04:10:14

标签: php pdo

在这种情况下,我绑定了一个命名参数:var

$var = 'John Doe';
$query = $db->prepare("SELECT * from `users` where user = :var");
$query->bindParam(":var", $var);
$query->execute();

但是现在,我需要将单个命名参数绑定两次,

$var = 'John Doe';
$query = $db->prepare("SELECT * from `users` as u left join `user_group` as ug on u.user_id = ug.user_id where u.user = :var and ug.user_name = :var");
$query->bindParam(":var", $var);
$query->execute();

所以,我的问题是,我可以设置bindParam单次或多次吗?

0 个答案:

没有答案