在PHP中,可以使用二进制数据类型进行过滤的方法有两种:
$binaryData = "\x0A\x0B\x0C";
$query = "SELECT * FROM table WHERE binary_column = ?";
$stmt = $pdo->prepare($query);
$stmt->execute([$binaryData]);
$binaryData = "\x0A\x0B\x0C";
$hexData = bin2hex($binaryData);
$query = "SELECT * FROM table WHERE binary_column = UNHEX(?)";
$stmt = $pdo->prepare($query);
$stmt->execute([$hexData]);
注意:在执行查询前,需要确保二进制数据类型的值是经过适当转义或过滤的,以防止SQL注入攻击。