【发布时间】:2016-01-01 17:45:11
【问题描述】:
我的 MYSQL 数据库包含 5 行
id, name, username, password, email, image
图像类型是 BLOB。
下面是我的 PHP 代码,用于从 MYSQL 获取 JSON 数据。
while($row = mysqli_fetch_array($res)){
array_push($result,
array('id'=>$row[0],
'name'=>$row[1],
'username'=>$row[2],
'password'=>$row[3],
'email'=>$row[4],
'image'=>$row[5])
));
}
echo json_encode(array("result"=>$result));
我的应用程序将加载比预期更长的时间来从返回的 JSON 中解析 base64 图像字符串。
那么高效存储和检索图像文件的最佳方法是什么?
【问题讨论】:
-
一个建议是将
imagepath而不是图像存储在您的db中,并在android 中显示来自您通过json收到的imagepath的图像 -
简单的答案是它完全没有效率。提高效率的唯一方法是不要将图像存储为 blob。
标签: php android mysql json image