在 PHP 中获取 BLOB 列时出现问题 MySQLi

发布于 2024-07-30 13:54:03 字数 427 浏览 3 评论 0原文

这是代码:

$conn = new mysqli('localhost', 'user', 'password', 'db');
$stmt = $conn->prepare('select Data  from sessions');
$stmt->execute();
$x = 234;
$stmt->bind_result($x);
$stmt->fetch();
var_dump($x);

输出:

字符串“”(长度=0)

事实上,该表仅包含一行,并且 blob 列包含一些有效的 ASCII 字符数据(一个 serialize()d PHP 整数)。

为什么会这样呢?

撞。

Here's the code:

$conn = new mysqli('localhost', 'user', 'password', 'db');
$stmt = $conn->prepare('select Data  from sessions');
$stmt->execute();
$x = 234;
$stmt->bind_result($x);
$stmt->fetch();
var_dump($x);

This outputs:

string '' (length=0)

In fact the table contains exactly one row and the blob column contains some valid ASCII character data (a serialize()d PHP integer).

Why is this so?

Bump.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

懷念過去 2024-08-06 13:54:03

MySQLi 可能不喜欢将 BLOB 数据放入 PHP 变量中。 如果您只需要存储 ASCII 数据,则应使用专为存储 ASCII 设计的列类型。

MySQLi probably doesn't like putting BLOB data into PHP variables. If you just need to store ASCII data, you should use a column type that's designed to store ASCII.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文