if (function_exists($_GET['displayResult']))
displayResult();
function displayResult() {
$db = new PDO('sqlite:ROS.sqlite');
$sql = 'select * from Item_Image_Large';
$result = $db->query($sql);
$rows[] = array();
while ($row = $result->fetchObject()) {
$rows['Item_Image_Large'][] = $row;
foreach ($rows as $key => $value) {
$newArrData[$key] = $rows[$key];
$newArrData[$key]['image_large'] = base64_encode($rows[$key]['image_large']);
}
}
header('Content-type: image/png');
$result2 = json_encode($newArrData);
echo $result2;
}
此代码用于从数据库获取BLOB数据并尝试将其转换为JSON格式,但它不起作用。 BLOB数据采用PNG格式。
答案 0 :(得分:0)
更改
header('Content-type: image/png');
到
header('Content-Type: application/json');