dprnr5559 2016-03-22 12:19
浏览 198

无法将长数据发送到mysql MEDIUMTEXT vs MEDIUMBLOB

I can only send data when string contains 523264 characters. HELP!

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();

i'v tried this but still same errors

"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."

Please HELP.

$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}
");
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}
");
echo "<br/><br/>";
if (!$stmt->execute())
die("Error executing prepared statement. {$stmt->error}
");

OK problem solved. I changed engine to MyISAM.

  • 写回答

2条回答 默认 最新

  • duanbage2161 2016-03-22 12:27
    关注

    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.

    Emphasis mine.

    You need to break the string down yourself, for instance with str_split($json_to_save, 100000);, then call send_long_data for each piece to be sent as chunks to the MySQL server.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大