1

我正在将二进制数据写入BYTEAUTF8 数据库中的字段。

当我通过 PHP/PDO 准备好的语句运行查询时,出现错误:

FATAL: SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0x98

知道为什么它将二进制数据视为应该是 utf8 编码的吗?

4

1 回答 1

2

Figured it out, the solution is that PG doesn't allow binary data to be passed as a regular 'string' value, it has to be treated as a special 'large object'.

$stmt->bindValue(1, $field_data, PDO::PARAM_LOB);
于 2013-04-14T16:40:50.323 回答