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


PHP ORM::insert方法代码示例

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


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

示例1: DPRT

 if ($org && $org->id()) {
     $launchkeys[org_id] = $org->id();
 } else {
     // Make sure to never get a org with a primary key of -1
     $launchkeys[org_id] = -1;
 }
 $launch->read($launchkeys);
 $launch->setall($launchkeys);
 // Set the foreign keys
 $launch->setall($_REQUEST, '/^launch_/');
 $launchpassword = md5(uniqid(rand(), true));
 if ($launch->id()) {
     $launch->update();
     DPRT("Updated launch={$launch->id}()");
 } else {
     $launch->insert();
     DPRT("Added launch={$launch->id}()");
 }
 // Log this digest
 $reqstr = mysql_real_escape_string(print_r($_REQUEST, TRUE));
 $quer = "insert into lti_digest (created_at, digest, request) values (NOW(), '{$digest}', '{$reqstr}');";
 mysql_query($quer);
 // Time to return a response, we either return a web service
 // response, debug outtput, or redirect back to ourselves
 $theurl = $_SERVER[SCRIPT_URI];
 $theuri = $_SERVER[REQUEST_URI];
 $i = strpos($theuri, '?');
 if ($i > 0) {
     $theurl = $theurl . substr($theuri, $i) . '&';
 } else {
     $theurl = $theurl . '?';
开发者ID:csev,项目名称:cloudcollab,代码行数:31,代码来源:launch.php

示例2: ORM

    }
    if ($key == 0) {
        // image handling
        if (!empty($_FILES['image']['name'])) {
            $image_path = "images/users/" . $_FILES['image']['name'];
            move_uploaded_file($_FILES["image"]["tmp_name"], $image_path);
            $image = $_FILES['image']['name'];
        } else {
            $image = 'default.png';
        }
        // database insertion
        require_once 'database/model.php';
        $mydb = new ORM();
        $mydb->setTable("users");
        $user = array('name' => $_POST["name"], 'email' => $_POST["email"], 'password' => hash("md5", $_POST['password']), 'room_no' => $_POST["room"], 'ext' => $_POST["ext"], 'is_admin' => 0, 'pic' => $image);
        $result = $mydb->insert($user);
        header("Location: Users.php");
    }
}
?>

	    <h1>Add User</h1>
		<form method="post" action="AddUser.php" class="form-horizontal" enctype="multipart/form-data">
			<div class="form-group panel">
				<label class="control-label">Name</label>
				<input required type="name" name="name" class="form-control ">
                <label class="control-label">Email</label>
				<input required type="email" name="email" class="form-control" >
                <label class="control-label">Password</label>
				<input required type="password" name="password" class="form-control">
                <label class="control-label">Confirm Password</label>
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:31,代码来源:AddUser.php

示例3: ORM

    if ($key == 0) {
        // image handling
        if (!empty($_FILES['image']['name'])) {
            $image_path = "images/products/" . $_FILES['image']['name'];
            move_uploaded_file($_FILES["image"]["tmp_name"], $image_path);
            $image = $_FILES['image']['name'];
        } else {
            $image = 'default.jpg';
        }
        // database insertion
        $selected = $cat_db->select(array('name' => $_POST["category"]));
        $category = $selected->fetch_assoc();
        $prod_db = new ORM();
        $prod_db->setTable("products");
        $product = array('name' => $_POST["product_name"], 'price' => $_POST["price"], 'category_id' => $category[id], 'is_available' => 1, 'pic' => $image);
        $result = $prod_db->insert($product);
        header("Location: Products.php");
    }
}
?>

        <h1>Add Product</h1>
		<form method="post" action="AddProduct.php" class="form-horizontal" enctype="multipart/form-data">
			<div class="form-group panel">
				<label class="control-label">Prduct Name</label>
				<input required type="text" name="product_name" class="form-control"><br>
                <label>Price</label><br>
				<input required type="number" name="price" min="0" class="form-control price" > <span class="desc">EGP</span> <br>
                <label class="control-label">Category</label><br>
				<select class="form-control category" name="category">
					<option disabled selected hidden>Category</option>
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:31,代码来源:AddProduct.php

示例4: ORM

	<div class="container" id="wrapper">
		<?php 
require_once 'database/model.php';
if ($_POST) {
    $key = 0;
    if (empty($_POST["category_name"])) {
        echo "<h4 class='alert-danger'> Category name is required</h4>";
        $key = 1;
    }
    if ($key == 0) {
        // database insertion
        $cat_db = new ORM();
        $cat_db->setTable("categories");
        $category = array('name' => $_POST["category_name"]);
        $result = $cat_db->insert($category);
        header("Location: Products.php");
    }
}
?>

        <h1>Add Category</h1>
		<form method="post" action="AddCategory.php" class="form-horizontal" enctype="multipart/form-data">
			<div class="form-group">
				<label class="control-label">Category Name</label>
				<input required type="text" name="category_name" class="form-control"><br>

				<button type="submit" value="Submit" class="btn btn-info">Submit</button>
  			</div>
		</form>
	</div>
开发者ID:Mohamed-Ashour,项目名称:MyCafe,代码行数:30,代码来源:AddCategory.php


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