<?php

	header('Content-Type: application/json');
	ini_set('display_startup_errors',1);
	ini_set('display_errors',1);
	error_reporting(1);
	ini_set("log_errors", 1);
	ini_set("error_log", "php-error.log");

	date_default_timezone_set('Asia/Kolkata');

	require_once("database.php");


	class ProductList
	{
		private $conn;

		function __Construct()
		{
			$dbconnect = new Database();
			$this->conn = $dbconnect->getConnection();

		}


		function getProductList()
		{

		   try{

				$stmt  = $this->conn->prepare("select * from my_product");
				$stmt->execute();
				$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
			 	return $result;
			
			  }catch(Exception $err){

				return 0;

			  } 


		
		}
    }

	$result = array();
	$product = new ProductList();
    $productList = $product->getProductList();

	$result['success'] = true;
	$result['message'] = "Product List!";
	$result['productList'] = $productList; 
	echo json_encode($result);



?>

