include_once '../classes/Logger.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$log = new Logger(basename($_SERVER['PHP_SELF']));
$response = array();
$log->arrayLogger($_POST, "POST Req Data");
$item_per_page = 5;
//item to display per page
if (isset($_POST['page_index'])) {
    $page_start = $_POST['page_index'];
    $page_position = ($page_start - 1) * $item_per_page;
} else {
    $page_position = $utilities->replaceZero($_POST['page_start']);
}
$chef_id = $utilities->replaceDefault($_POST['chef_id']);
$dateTime = $utilities->replaceNow();
//print_r($_POST);
try {
    $query = " SELECT food_item.item_id,\n                        food_item.`name` AS food_name,\n                        food_item.description,\n                        food_item.ingredients,\n                        food_item.preparation_method,\n                        food_item.rating AS food_rating,\n                        category.category_id,\n                        category.category_name,\n                        food_item.price,\n                        currency.currency_id,\n                        currency.currency_name,\n                        currency.currency_symbol,\n                        chef.chef_id,\n                        CONCAT(chef.f_name, ' ', chef.l_name) AS chef_name,\n                        CONCAT(chef.country_code, chef.phone_number) AS chef_phone_number,\n                        chef.image_url AS chef_image,\n                        chef.rating AS chef_rating,\n                        food_item.nutrition,\n                        COALESCE(food_item.food_image_1, '') AS food_image_1,\n                        COALESCE(food_item.food_image_2, '') AS food_image_2,\n                        COALESCE(food_item.food_image_3, '') AS food_image_3,\n                        COALESCE(food_item.food_image_4, '') AS food_image_4,\n                        food_item.log_datetime\n                FROM food_item INNER JOIN category ON food_item.category_id = category.category_id\n                         INNER JOIN currency ON food_item.currency_id = currency.currency_id\n                         INNER JOIN chef ON food_item.chef_id = chef.chef_id ";
    $query .= $chef_id > 0 ? " WHERE food_item.chef_id = {$chef_id} " : " ";
    $query .= " ORDER BY food_name ASC\n                LIMIT {$page_position}, {$item_per_page};";
    //echo $query;
    $log->info("Query:" . $query);
    $statement = $dbConnection->prepare($query);
    $sql = "SELECT * FROM food_item";
    $result = $dbConnection->query($sql);
    $row = $result->fetchAll();
    $numOfRows = count($row);
    try {
        if ($statement->execute($bindParams)) {
            $data = $statement->fetchAll(PDO::FETCH_ASSOC);
<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$name = $utilities->clean($_POST['name']);
$area = $utilities->clean($_POST['area']);
$pincode = $utilities->clean($_POST['pincode']);
$latitude = $utilities->replaceZero($_POST['latitude']);
$longitude = $utilities->replaceZero($_POST['longitude']);
$log_datetime = $utilities->replaceNow();
$kitchenId = -1;
try {
    $insertQuery = "INSERT INTO " . " `kitchen` (name, area, pincode, latitude, longitude, log_datetime) " . " VALUES ('{$name}', '{$area}', '{$pincode}', '{$latitude}', '{$longitude}', '{$log_datetime}')";
    $statement = $dbConnection->prepare($insertQuery);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $kitchenId = $dbConnection->lastInsertId();
            $dbConnection->commit();
            $response = array('status' => $kitchenId, 'desc' => 'Success');
        } else {
            $status = -99;
            $dbError = $statement->errorInfo();
            $response = array('status' => $status, 'desc' => 'DB error occured' . $dbError[2]);
        }
    } catch (PDOExecption $e) {
        $status = -7;
        $error = "Exception: " . $e->getMessage();