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


PHP ORM::getInstance方法代码示例

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


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

示例1:

<?php

require 'database/model.php';
$obj = ORM::getInstance();
$order_id = $_POST['order_id'];
//first delete from table orders
$obj->setTable('orders');
$no_row_afected = $obj->delete(array('id' => $order_id));
if ($no_row_afected > 0) {
    $obj->setTable('order_product');
    $no_product_afected = $obj->delete(array('order_id' => $order_id));
}
echo $no_row_afected;
echo $no_product_afected;
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:14,代码来源:delete_order.php

示例2: session_start

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
  </head>
  <?php 
session_start();
if (isset($_SESSION['userName'])) {
    header("Location: ../layout/collapsed-sidebar.php");
}
require '../../ormProject.php';
require '../../validation.php';
$connection = ORM::getInstance();
$connection->setTable('user');
if ($_POST) {
    $validation = new Validation();
    $rules = array('Email' => 'email|required', 'Password' => 'required');
    if ($validation->validate($_POST, $rules) == true) {
        $Email = $_POST['Email'];
        $Password = $_POST['Password'];
        $data = array('password' => md5($Password), 'email' => $Email);
        $result = $connection->selectRow("*", $data);
        if ($result) {
            // session_start();
            $_SESSION['userId'] = $result['userId'];
            $_SESSION['userName'] = $result['userName'];
            $id = $result['userId'];
            $_SESSION['admin'] = $result['admin'];
开发者ID:rababZein,项目名称:BookShop,代码行数:30,代码来源:login.php

示例3: while

<?php

require 'database/model.php';
//get or=der_id from the request
$order_id = $_POST['order_id'];
//echo $order_id;
/**
 * select query from table order_product  to get all products
 */
$obj_order = ORM::getInstance();
$obj_order->setTable('order_product');
$result = $obj_order->select(array('order_id' => $order_id));
$info = "";
//get all information in string to gend back to javascript
//getting the relation between order and product from table order_product
//then get from this relation the product_id to get information about each prosuct in the order
while ($order = $result->fetch_assoc()) {
    $obj_product = ORM::getInstance();
    $obj_product->setTable('products');
    $result_pro = $obj_product->select(array('id' => $order['product_id']));
    $result_product = $result_pro->fetch_assoc();
    $info .= $result_product['name'] . ";" . $result_product['pic'] . ";" . $order['amount'] . ";" . $order['total_price'] . ",";
}
echo $info;
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:24,代码来源:user_get_order_products.php

示例4: while

            </div>

            <div class="row panel-body">
                <div class="col-md-6">

                    <div class="panel panel-heading">

                        <h2> User: </h2>
                    </div>

                    <select class=" form-control" id="user_name">
                        <?php 
/**
 * get all users name
 */
$obj_users = ORM::getInstance();
$obj_users->setTable('users');
$all_users = $obj_users->select(array('is_admin' => 0));
if ($all_users->num_rows > 0) {
    while ($user = $all_users->fetch_assoc()) {
        ?>
                                <option value="<?php 
        echo $user['name'];
        ?>
"> <?php 
        echo $user['name'];
        ?>
 
                                    <?php 
    }
} else {
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:31,代码来源:Checks.php

示例5: header

<?php

include_once "ORM.php";
$db = ORM::getInstance();
$db->setTable('Book');
//
if ($_POST['flag'] == '1') {
    $upfile = "./images/bookimages/" . $_FILES['bookPicture']['name'];
    $image_name = $_FILES['bookPicture']['name'];
    $image_path = "./images/bookimages/" . $image_name;
    $image_error = "";
    if ($_FILES['bookPicture']['type'] != 'image/png') {
        $image_error = '* image is not png';
    }
    if (is_uploaded_file($_FILES['bookPicture']['tmp_name'])) {
        if (!move_uploaded_file($_FILES['bookPicture']['tmp_name'], $upfile)) {
            $image_error = '* Could not move image to destination directory';
        }
    }
    //
    $mysqli = $db->insert(array('bookName' => $_POST['bookName'], 'bookAuther' => $_POST['bookAuther'], 'bookDescription' => $_POST['bookDescription'], 'bookBody' => $_POST['bookBody'], 'bookPicture' => $image_name, 'categoryId' => $_POST['category']));
    header("Location: ./index.php");
} elseif ($_POST['flag'] == '2') {
    //$imgname=$db->select('categoryPicture',array('product_id'=>$_POST['id']));
    $mysqli = $db->delete(array('id' => $_POST['id']));
    // unlink('images/categoryimages/'.trim($imgname));
    echo '{"id":"add"}';
} elseif ($_POST['flag'] == '3') {
    $mysqli = $db->select('*', array('id' => $_POST['id']));
    echo json_encode(mysqli_fetch_assoc($mysqli));
} else {
开发者ID:AmanyMohammed,项目名称:Task,代码行数:31,代码来源:book.php

示例6: array

<?php

require 'database/model.php';
/**
 * update the statues of order acording to it`s id 
 */
$order_id = $_POST['order_id'];
$status = $_POST['status'];
$obj_order = ORM::getInstance();
$obj_order->setTable('orders');
$result = $obj_order->update(array('id' => $order_id), array('status' => $status));
echo $result;
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:12,代码来源:order_status.php

示例7: explode

$status = "processing";
/**
 * insert order into database
 */
$obj_order = ORM::getInstance();
$obj_order->setTable('orders');
$result = $obj_order->insert(array("user_id" => $user_id, "status" => $status, "order_price" => $order_price, "room_id" => $order_room));
/**
 * select the last order to get order_id
 */
$obj_order_id = ORM::getInstance();
$obj_order_id->setTable('orders');
$last_order = $obj_order_id->select_last_row(array("user_id" => $user_id));
$order_id = $last_order['id'];
/**
 *  insert into table order_product all products of the order
 */
$notes = $_POST['notes'];
$products_array = $_POST['array'];
//getting all products separated by comma
$products = explode(",", $products_array);
//getting information obout each product and insert it into order_product table
for ($i = 0; $i < count($products) - 1; $i++) {
    $product = explode(":", $products[$i]);
    $obj_order_product = ORM::getInstance();
    $obj_order_product->setTable('order_product');
    $product_id = $product[0];
    $product_amount = $product[1];
    $product_price = $product[2];
    $obj_order_product->insert(array("order_id" => $order_id, "product_id" => $product_id, "amount" => $product_amount, "total_price" => $product_price, "notes" => $notes));
}
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:31,代码来源:admin_order.php

示例8:

">
                                        <?php 
            ?>
                                        <div class="row">
                                            <?php 
            echo "Amount: " . $current_product['amount'];
            ?>
                                        </div>
                                        <div class="row">
                                            <?php 
            echo " totalPrice: " . $current_product['total_price'];
            ?>
                                        </div>
                                        <?php 
            //get the name of product and all it`s info
            $obj_product_info = ORM::getInstance();
            $obj_product_info->setTable('products');
            $product_info_array = $obj_product_info->select(array('id' => $current_product['product_id']));
            $product_info = $product_info_array->fetch_assoc();
            ?>
                                        <div class="row">
                                            <?php 
            echo " Name: " . $product_info['name'];
            ?>
                                        </div>
                                        <div class="row">
                                            <img src="<?php 
            echo "images/products/" . $product_info['pic'];
            ?>
" class="img-responsive img-circle"  width="120px" height="120px">
                                        </div>
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:31,代码来源:AdminHome.php

示例9: while

    $obj_order_product->setTable('order_product');
    $product_id = $product[0];
    $product_amount = $product[1];
    $product_price = $product[2];
    $obj_order_product->insert(array("order_id" => $order_id, "product_id" => $product_id, "amount" => $product_amount, "total_price" => $product_price, "notes" => $notes));
}
/**
 * select all user information
 */
$obj_user = ORM::getInstance();
$obj_user->setTable('users');
$user_info = $obj_user->select(array("id" => $user_id));
$user = $user_info->fetch_assoc();
/**
 * select all order_products info
 */
$order_product = ORM::getInstance();
$order_product->setTable('order_product');
$order_info = $order_product->select(array("order_id" => $order_id));
$products_count = $order_info->num_rows;
$string_info = $last_order['id'] . ";" . $last_order['datetime'] . ";" . $user['name'] . ";" . $user['ext'] . ";" . $last_order['room_id'] . ";";
//$i=0;
while ($order = $order_info->fetch_assoc()) {
    $order_product_info_obj = ORM::getInstance();
    $order_product_info_obj->setTable('products');
    $order_product_info = $order_product_info_obj->select(array("id" => $order['product_id']));
    $product = $order_product_info->fetch_assoc();
    $string_info .= $product['name'] . "/" . $product['pic'] . "/" . $order['amount'] . "/" . $order['total_price'] . "%";
}
$string_info .= ";" . $last_order['order_price'];
echo $string_info;
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:31,代码来源:user_order.php


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