0
我創建Smarty中列出數據的函數。它工作正常,但我的問題是我得到的數據兩次。請幫助我。Json編碼獲取重複數據
我的功能是如下: -
function appListing($requestvars)
{
try
{
$rh = $this->db->prepare('SELECT * FROM app');
//$rh->bindParam(':userOwnerId', $_SESSION['userId'], PDO::PARAM_STR);
$rh->execute();
$appData['App'] = $rh->fetchAll();
$this->smartyTemplate->assign('appData', $appData);
$this->smartyTemplate->assign('request', $requestvars);
$this->smartyTemplate->assign('homePath', APP_ROOT_DIR);
//$this->smartyTemplate->display('project/appList.html');
}
catch (PDOException $e)
{
$appData = "Error!: " . $e->getMessage();
}
echo json_encode($appData);
}
輸出我得到是如下: -
{
"App": [
{
"0": "app_57ba9fc847dd55_57218508",
"1": "旅行臺南",
"2": "https://play.google.com/",
"3": "https://play.google.com/1471848392.png",
"4": "1471848392",
"5": "1471848392",
"appId": "app_57ba9fc847dd55_57218508",
"appName": "旅行臺南",
"appURL": "https://play.google.com/",
"appImage": "https://play.google.com/1471848392.png",
"createTime": "1471848392",
"lastUpdateTime": "1471848392"
}
我想輸出: -
{
"App": [
{
"appId": "app_57ba9fc847dd55_57218508",
"appName": "旅行臺南",
"appURL": "https://play.google.com/",
"appImage": "https://play.google.com/1471848392.png",
"createTime": "1471848392",
"lastUpdateTime": "1471848392"
}
請幫我...謝謝
謝謝...其工作 –