if(!empty($_POST)){
if (isset($_POST['id']) && $_POST['id'] > 0){
$id=$_POST['id'];
GetSuppliersView();
}
}
function GetSuppliersView() {
global $db;
global $id;
try{
$query = $db->query("
SELECT
suppliers.*,
third_party_services.name as servicename
FROM
suppliers
INNER JOIN
suppliers_services
ON
suppliers.id = suppliers_services.supplier_id
LEFT JOIN
third_party_services
ON
suppliers_services.id = third_party_services.id
WHERE
suppliers_services.supplier_id = $id
");
$row=$query->fetch(PDO::FETCH_ASSOC);
$result['success'] = true;
$result['result'] = $row;
echo json_encode($result);
return true;
} catch (PDOException $pe) {
return false;
}
}
你可以帮我吗?
答案 0 :(得分:-1)
请试试这个
$query->setFetchMode(PDO::FETCH_CLASS, 'Person');
$row = $query->fetch();
而不是
$row=$query->fetch(PDO::FETCH_ASSOC);