#生成预处理对象 $sql = 'SELECT * FROM dede_archives WhERE id IN (:id)' ; $stmt = $pdo -> prepare($sql); #参数的绑定并执行 $id = implode(',',[2,3,4,5,6,7,8,9]); #$stmt -> bindParam(':id',$id,PDO::PARAM_STR); $stmt -> bindValue(':id','2,3,4,5,6,7,8,9',PDO::PARAM_STR); $stmt -> execute(); 结果只能查询到id为2的数据,其他id的数据查询不到! 在传递这些多个值的时候或者多条件的时候应该怎样写;
7tian.work2018-11-14 10:53:48
TP5.1.21 After version, array query support:
To achieve this subquery:
1. First quote: use think\db\Where;
2. Define the array: $where = new Where;
3. You can use it: $where['title'] = ['like', "%".$sotitle."%"];
Reference address: https://blog.csdn.net/haibo0668/article/details/78295485