prepare("INSERT INTO json_t (json_-6ren">
gpt4 book ai didi

php - 无法将长数据发送到 mysql MEDIUMTEXT 或 MEDIUMBLOB

转载 作者:行者123 更新时间:2023-11-30 22:23:00 26 4
gpt4 key购买 nike

我只能在字符串包含 523264 个字符时发送数据。帮助!

include("conn.php");

$stmt = $conn->prepare("INSERT INTO json_t (json_string) VALUES (?)");
$null = NULL;
$stmt->bind_param("b",$null);

$stmt->send_long_data(0, $json_to_save);

$stmt->execute();
$stmt->close();
$conn->close();

我试过了,还是一样的错误

"Error executing prepared statement. Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline."

请帮助。

$stmt = $conn->prepare("INSERT INTO json_t (json_string) VALUES (?)");
$null = NULL;
$stmt->bind_param("b",$null);

$max_allowed_packet = 100000;
if (!$stmt->bind_param('b', $null))
die("Error binding parameters. {$stmt->error}\n");
echo "<br/><br/>";
foreach(str_split($v, $max_allowed_packet) as $packet )
if (!$stmt->send_long_data(0, $packet))
die("Error sending long packet. {$stmt->error}\n");
echo "<br/><br/>";
if (!$stmt->execute())
die("Error executing prepared statement. {$stmt->error}\n");

好的,问题解决了。我将引擎更改为 MyISAM。

最佳答案

Allows to send parameter data to the server in pieces (or chunks), e.g. if the size of a blob exceeds the size of max_allowed_packet. This function can be called multiple times to send the parts of a character or binary data value for a column, which must be one of the TEXT or BLOB datatypes.

强调我的。

您需要自己分解字符串,例如使用 str_split($json_to_save, 100000);,然后调用 send_long_data 将每个片段作为 block 发送到MySQL 服务器。

关于php - 无法将长数据发送到 mysql MEDIUMTEXT 或 MEDIUMBLOB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36154227/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com