在PHP中,可以使用二進(jìn)制數(shù)據(jù)類型進(jìn)行過濾的方法有兩種:
$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]);
注意:在執(zhí)行查詢前,需要確保二進(jìn)制數(shù)據(jù)類型的值是經(jīng)過適當(dāng)轉(zhuǎn)義或過濾的,以防止SQL注入攻擊。