当我的 MySQl 数据类型为 bit(1) 时,但用 php 打印时json_encode
会用 unicode 写入?IIS 工作正常,
但在我的专用服务器中,Apache 托管将变为 unicode。为什么?
你可以看到 Mysql 上的Locating
,Locating
数据类型是位的,但是打印的是 \u0001? 为什么?
get-googlemarker.php
这是我得到这个结果的编码 GET 方法
<?php
mysql_connect("localhost", "root", "123456") or die("Could not connect");
mysql_select_db("db_gps") or die("Could not select database");
$parent_id = $_GET['mainid'];
$query = "SELECT *
FROM tbl_locate AS a
INNER JOIN
(
SELECT MainID, Max(DateTime) AS DateTime
FROM tbl_locate
GROUP BY MainID
) AS b
ON a.MainID = b.MainID
AND a.DateTime = b.DateTime
LEFT JOIN
(
SELECT b.PicData
, b.PicUploadedDateTime
, b.MainID
FROM (SELECT MainID,Max(PicUploadedDateTime) as PicUploadedDateTime
FROM tbl_picture
group by MainID
) l
JOIN tbl_picture b
ON b.MainID = l.MainID AND b.PicUploadedDateTime = l.PicUploadedDateTime
) AS c
ON a.MainID = c.MainID";
$rs = mysql_query($query);
$arr = array();
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
echo json_encode($arr);
?>
更新
表示数据是正确的,但问题是当我使用下面的 javascript 时,我无法读取定位值,我已经尝试alert
了记录,但是是空白的。我尝试使用type:string
, type:bit
, type:bytes
,进行定位type:int
,
但不起作用。无法显示任何内容alert
Ext.define('GoogleMarkerModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'ID', type: 'int'},
{name: 'Locating', type: 'int'},
{name: 'MainPower', type: 'int'},
{name: 'Acc', type: 'int'},
{name: 'PowerOff', type: 'int'},
{name: 'Alarm', type: 'int'},
{name: 'Speed', type: 'int'},
{name: 'Direction', type: 'int'},
{name: 'Latitude', type: 'float'},
{name: 'Longitude', type: 'float'},
{name: 'DateTime', type: 'datetime'},
{name: 'MainID', type: 'int'},
{name: 'IOState', type: 'int'},
{name: 'OilState', type: 'int'},
{name: 'PicUploadedDateTime', type: 'datetime'},
{name: 'PicData', type: 'str'}
]
});