Hi,
I have the following SQL:
SELECT customers_address.customer_address_id, address_category.address_category_name, customers_address.address_name,
address_details.address_details_id,
address_details.address_details_text
FROM customers_address
JOIN address_category ON address_category.address_category_id = customers_address.address_category_id
LEFT JOIN address_details ON address_details.customer_address_id = customers_address.customer_address_id
WHERE customer_id = param_customer;
I want to show this output in JSON:
CustomerAddress:
{
customer_address_id
address_category_name
address_name
}
Details:
{
address_details_id
address_details_text
}
my current php is:
$mysql_query = $mysql_connection->prepare('CALL sp_populate_customer_addresses(:param_customer)');
$mysql_query->bindParam(':param_customer', $customer_id, PDO::PARAM_STR);
$mysql_query->execute();
if ($mysql_query->rowCount() <= 0) { echo "false"; }
else
{
$jsonData = array();
while($mysql_row = $mysql_query->fetch())
{
$jsonData[] = $mysql_row;
}
echo json_encode($jsonData);
}
Thanks,
Jassim