gpt4 book ai didi

php - mysql逐行插入数据

转载 作者:行者123 更新时间:2023-11-29 18:26:33 27 4
gpt4 key购买 nike

要求在一个mysql列中插入多行(像show这样的换行符并不意味着在多行中插入数据有多个变量包含不同的url,例如

想要将这些值存储在一个 mysql 列中,每个值应该在新行中,引用图像描述更好

要求在一个 mysql 列中插入多行(使用像换行符之类的东西并不意味着在多行中插入数据

最佳答案

如果您在 php 中尝试,那么您可以序列化数据并将其作为单列存储在数据库中。

在检索数据时,我们可以反序列化并将数据作为数组获取。查找下面的示例。

<?php
$var = array();
$var[0] = "http://example.com";
$var[1] = "http://example.org";
$var = array("1","2","3");
print_r($var); // Array ( [0] => http://example.com [1] => http://example.org )

$b=serialize($var);

echo $b; // a:2:{i:0;s:18:"http://example.com";i:1;s:18:"http://example.org";}

$c=unserialize($b);

print_r($c); // Array ( [0] => http://example.com [1] => http://example.org )

关于php - mysql逐行插入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46144054/

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