当前位置: 首页>>代码示例>>PHP>>正文


PHP Utilities::replaceDefault方法代码示例

本文整理汇总了PHP中Utilities::replaceDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::replaceDefault方法的具体用法?PHP Utilities::replaceDefault怎么用?PHP Utilities::replaceDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utilities的用法示例。


在下文中一共展示了Utilities::replaceDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PDOExt

<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$serving_id = $utilities->replaceDefault($_POST['serving_id']);
$date = $utilities->replaceToday($_POST['date']);
$userId = $utilities->replaceZero($_POST['user_id']);
try {
    $query = "SELECT food_item.item_id AS food_id,\n                        food_item.`name` AS food_name,\n                        food_item.description AS food_description,\n                        food_item.ingredients AS food_ingredients,\n                        food_item.preparation_method AS food_preparation_method,\n                        food_item.rating AS food_rating,\n                        food_item.price AS food_price,\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.category_id,\n                        currency.currency_symbol AS food_currency_symbol,\n                        food_item.chef_id,\n                        CONCAT(chef.f_name, ' ', chef.l_name) AS chef_name,\n                        chef.image_url AS chef_image_url,\n                        chef.rating AS chef_rating,\n                        serving.serving_name,\n                        item_serving_mapping.available_for AS available_for_count,\n                        item_serving_mapping.order_count,\n                        item_serving_mapping.date AS serving_date,\n                        (SELECT COUNT(*) FROM `likes` WHERE food_item_id = food_id) AS likes_count,\n                        (SELECT COUNT(*) FROM `likes` WHERE food_item_id = food_id AND likes.user_id = '{$userId}' ) AS liked_already,\n                        category.category_id,\n                        category.category_name\n                FROM item_serving_mapping INNER JOIN food_item ON item_serving_mapping.item_id = food_item.item_id\n                         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\n                         INNER JOIN serving ON item_serving_mapping.serving_id = serving.serving_id ";
    $query .= " WHERE (item_serving_mapping.date = '{$date}'  OR item_serving_mapping.date = '1970-01-01') ";
    $query .= $serving_id > 0 ? " AND item_serving_mapping.serving_id = {$serving_id} " : " ";
    $query .= "ORDER BY item_serving_mapping.serving_id ASC, food_rating ASC, food_name ASC";
    $statement = $dbConnection->prepare($query);
    try {
        if ($statement->execute($bindParams)) {
            $data = $statement->fetchAll(PDO::FETCH_ASSOC);
            $statement->closeCursor();
            $response = array('status' => 0, 'data' => $data, 'desc' => 'success');
        } else {
            $errorCode = -99;
            $dbError = $statement->errorInfo();
            $statement->closeCursor();
            $response = array('status' => $errorCode, 'data' => array(), 'desc' => 'DB error occured' . $dbError[2]);
        }
    } catch (PDOExecption $e) {
        $errorCode = -7;
        $statement->closeCursor();
        $error = "Exception: " . $e->getMessage();
开发者ID:saptharsh,项目名称:Single-Page-Application,代码行数:31,代码来源:GetMenu.php

示例2: PDOExt

include_once '../classes/Utilities.php';
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)) {
开发者ID:saptharsh,项目名称:Single-Page-Application,代码行数:31,代码来源:GetFoodItems.php

示例3: PDOExt

<?php

include_once '../classes/PDOExt.php';
include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$user_id = $utilities->replaceDefault($_POST['user_id']);
try {
    $query = "SELECT food_item.`name` AS food_name,\n                        food_item.description,\n                        food_item.ingredients,\n                        food_item.nutrition,\n                        food_item.preparation_method,\n                        food_item.food_image_1,\n                        food_item.food_image_2,\n                        food_item.food_image_3,\n                        food_item.food_image_4,\n                        food_item.rating,\n                        food_item.price,\n                        CONCAT(chef.f_name, chef.l_name) AS chef_name,\n                        chef.rating AS chef_rating,\n                        chef.image_url\n                FROM likes INNER JOIN food_item ON likes.food_item_id = food_item.item_id\n                         INNER JOIN chef ON food_item.chef_id = chef.chef_id\n                WHERE likes.user_id = '{$user_id}'";
    $statement = $dbConnection->prepare($query);
    try {
        if ($statement->execute($bindParams)) {
            $data = $statement->fetchAll(PDO::FETCH_ASSOC);
            $statement->closeCursor();
            $response = array('status' => 0, 'data' => $data, 'desc' => 'success');
        } else {
            $errorCode = -99;
            $dbError = $statement->errorInfo();
            $statement->closeCursor();
            $response = array('status' => $errorCode, 'data' => array(), 'desc' => 'DB error occured' . $dbError[2]);
        }
    } catch (PDOExecption $e) {
        $errorCode = -7;
        $statement->closeCursor();
        $error = "Exception: " . $e->getMessage();
        $response = array('status' => $errorCode, 'data' => array(), 'desc' => 'PDO exception occured' . $error);
    }
} catch (PDOExecption $e) {
    $errorCode = -8;
    $error = "Exception: " . $e->getMessage();
开发者ID:saptharsh,项目名称:Single-Page-Application,代码行数:31,代码来源:GetPreferedList.php


注:本文中的Utilities::replaceDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。