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


PHP Utilities::replaceOne方法代码示例

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


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

示例1: PDOExt

include_once '../classes/Utilities.php';
$dbConnection = new PDOExt();
$utilities = new Utilities();
$response = array();
$basket_code = uniqid("BSKT_");
/*
 * Json array with id, qunatity in this format.
 * [
 *  {'item':1,'name': 'xyz','quantity':2,'price':200},
 *  {'item':2,'name': 'abc','quantity':1,'price':150},
 *  {'item':3,'name': 'qwert','quantity':1,'price':20},
 *  {'item':4,'name': 'poiuyt','quantity':1,'price':30}
 * ]
 */
$item_quantity_price_json = $utilities->clean($_POST['item_quantity_price_json']);
$user_id = $utilities->replaceOne($_POST['user_id']);
$time_slot_id = $utilities->replaceOne($_POST['time_slot_id']);
$status = $utilities->replaceOne($_POST['status']);
$date = $utilities->replaceToday($_POST['date']);
$address_id = $utilities->replaceZero($_POST['address_id']);
$order_type_id = $utilities->replaceZero($_POST['order_type_id']);
$log_datetime = $utilities->replaceNow();
$order_id = -1;
try {
    $insertQuery = "INSERT INTO " . " `order` (basket_code, user_id, item_quantity_price_json, time_slot_id, status, date, address_id, log_datetime) " . " VALUES ('{$basket_code}', '{$user_id}', '{$item_quantity_price_json}', '{$time_slot_id}', '{$status}', '{$date}', '{$address_id}', '{$log_datetime}')";
    $statement = $dbConnection->prepare($insertQuery);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $order_id = $dbConnection->lastInsertId();
            $dbConnection->commit();
开发者ID:saptharsh,项目名称:Single-Page-Application,代码行数:31,代码来源:InsertOrder.php

示例2: Utilities

$utilities = new Utilities();
$response = array();
$name = $utilities->clean($_POST['name']);
$description = $utilities->clean($_POST['description']);
$ingredients = $utilities->clean($_POST['ingredients']);
$preparation_method = $utilities->clean($_POST['preparation_method']);
$nutrition = $utilities->clean($_POST['nutrition']);
$food_image_1 = $utilities->clean($_POST['food_image_1']);
$food_image_2 = $utilities->clean($_POST['food_image_2']);
$food_image_3 = $utilities->clean($_POST['food_image_3']);
$food_image_4 = $utilities->clean($_POST['food_image_4']);
$food_image_5 = $utilities->clean($_POST['food_image_5']);
$food_image_6 = $utilities->clean($_POST['food_image_6']);
$rating = $utilities->replaceZero($_POST['rating']);
$price = $utilities->replaceZero($_POST['price']);
$currency_id = $utilities->replaceOne($_POST['currency_id']);
$chef_id = $utilities->replaceZero($_POST['chef_id']);
$category_id = $utilities->replaceOne($_POST['category_id']);
$log_datetime = $utilities->replaceNow();
$foodId = -1;
try {
    $insertQuery = "INSERT INTO " . " `food_item` (name, description, ingredients, preparation_method, nutrition, food_image_1,food_image_2,food_image_3, food_image_4, food_image_5, food_image_6, rating, price, currency_id, chef_id, category_id, log_datetime) " . " VALUES ('{$name}', '{$description}', '{$ingredients}', '{$preparation_method}', '{$nutrition}', '{$food_image_1}', '{$food_image_2}','{$food_image_3}','{$food_image_4}','{$food_image_5}','{$food_image_6}', '{$rating}', '{$price}', '{$currency_id}', '{$chef_id}', '{$category_id}', '{$log_datetime}')";
    $statement = $dbConnection->prepare($insertQuery);
    try {
        $dbConnection->beginTransaction();
        if ($statement->execute()) {
            $foodId = $dbConnection->lastInsertId();
            $dbConnection->commit();
            $response = array('status' => $foodId, 'desc' => 'Success');
        } else {
            $status = -99;
开发者ID:saptharsh,项目名称:Single-Page-Application,代码行数:31,代码来源:InsertFoodItem.php


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