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


PHP Utilities::replaceNow方法代码示例

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


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

示例1: PDOExt

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

示例2: PDOExt

<?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();
开发者ID:saptharsh,项目名称:Single-Page-Application,代码行数:31,代码来源:InsertKitchen.php


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