<?php
	// required headers
	header("Access-Control-Allow-Origin: *");
	header("Content-Type: application/json; charset=UTF-8");
	 
	// include database and object files
	include_once '../config/database.php';
	include_once '../objects/store.php';
	 
	// instantiate database
	$database = new Database();
	$db = $database->getConnection();
	 
	// initialize object
	$store = new Store($db);

	$stmt = $store->getAllRows();
	$num = $stmt->rowCount();

	if($num>0){
		$arr=array();
		$arr["records"]=array();

		while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
			extract($row);
			$s=array(
				"id" => (int)$id,
				"store" => $store
			);
	 
			array_push($arr["records"], $s);
		}
	 
		echo json_encode($arr);
	}else{
		echo json_encode(
			array("message" => "No store found.")
		);
	}
?>