本文整理汇总了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 . '?';
示例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>
示例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>
示例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>