在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注入攻擊。