NexusDB compatible with binary field

This commit is contained in:
xiaomlove
2026-06-14 16:24:18 +07:00
parent fab32bf63d
commit c50867a71a
3 changed files with 31 additions and 5 deletions
+22
View File
@@ -568,4 +568,26 @@ class NexusDB
}
}
public static function binaryField(string $field): string
{
if (self::isMysql()) {
return sprintf("%s = :%s", $field, $field);
} elseif (self::isPgsql()) {
return sprintf("%s = decode(:%s, 'hex')", $field, $field);
} else {
throw new \RuntimeException('Not supported database.');
}
}
public static function binaryFieldBindValue($value): string
{
if (self::isMysql()) {
return $value;
} elseif (self::isPgsql()) {
return bin2hex($value);
} else {
throw new \RuntimeException('Not supported database.');
}
}
}