我创建了一个使用关联数组键的PDO语句但是当执行SQL时会添加“\”和“'”,我该如何防止这种情况?
这是查询
public function queryUpdateClasses($classesToUpdate,$packageId){
$sql = "SELECT class.ClassId FROM class JOIN package ON package.PackageId = class.PackageId WHERE class.ClassName = ? AND package.PackageId = ?";
$query = $this->_conn->prepare($sql);
foreach($classesToUpdate as $updateKey=>$updateValue){
echo $updateKey;
$query->execute(array($updateKey,$packageId));
}
}
以下是日志文件的输出
98 Query SELECT class.ClassId FROM class JOIN package ON package.PackageId = class.PackageId WHERE class.ClassName = '\'LogActivityTable\'' AND package.PackageId = '69'
当$updateKey;
被回显时,它只显示'LogActivityTable'。