【发布时间】:2015-02-05 10:48:22
【问题描述】:
我使用 php 序列化函数在 mysql 中存储了许多数组。
但问题是, 我怎样才能找到包含序列化数组的任何一个值。
我很困惑如何获取包含我的值的数组。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form method="get" action="test1.php">
<input type="text" name="first_singer"/><br>
<input type="text" name="second_singer"/><br>
<input type="submit" name="submit">
</form>
<?php
if(isset($_GET['submit'])){
$singer1=$_GET['first_singer'];
$singer2=$_GET['second_singer'];
$singer=array($singer1,$singer2);
$array=serialize( $singer );
$conn=mysqli_connect("localhost","root","","test2") or die();;
$array=serialize($singer);
$sql = "INSERT INTO `table` (`column`) VALUES ('$array')";
if(mysqli_query($conn,$sql)){
echo 'query susseful';
}
}
?>
</body>
</html>
【问题讨论】:
-
更好的方法是将数据保存到规范化数据库中,而不是序列化值。正如您现在看到的,从序列化数据中读取值需要付出巨大的努力。
-
我不知道规范化。所以给我最好的方法
-
您自己对规范化的研究结果如何?
标签: php mysql arrays serialization