本文整理汇总了PHP中Item::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::update方法的具体用法?PHP Item::update怎么用?PHP Item::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::update方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* @param : int $id
* @param : array $data
* @return boolean
*/
public static function update($id, $data)
{
if (!is_array($data) || !count($data)) {
return;
}
$shipFromData = $data['shipFrom'];
$shipToData = $data['shipTo'];
$itemData = $data['item'];
$companyData = $data['company'];
$query = "SELECT * FROM `order` WHERE id = :id";
$param = array('id' => $id);
$result = DB::select($query, $param);
if (count($result) > 0) {
$order = $result[0];
$shipToId = $order->ship_to ? $order->ship_to : 0;
$shipFromId = $order->ship_from ? $order->ship_from : 0;
$itemId = $order->item_id ? $order->item_id : 0;
$companyId = $order->company_id ? $order->company_id : 0;
ShipFrom::update($shipFromId, $shipFromData);
ShipTo::update($shipToId, $shipToData);
Item::update($itemId, $itemData);
Company::update($companyId, $companyData);
return true;
}
}
示例2: update
public static function update($item_id)
{
$params = $_POST;
$attributes = array('item_id' => $item_id, 'type' => $params['type'], 'brand' => $params['brand'], 'color' => $params['color'], 'color_2nd' => $params['color_2nd'], 'material' => $params['material'], 'image' => $params['image']);
$edited_item = new Item($attributes);
$errors = $edited_item->errors();
if (count($errors) > 0) {
//luodaan editointinäkymä uudelleen virheilmoitusten kanssa
View::make('items/edit.html', array('errors' => $errors, 'attributes' => $attributes));
} else {
//kutsutaan luodun olion update-metodia
$edited_item->update();
//Ohjataan käyttäjä luodun vaatteen sivulle viestin kanssa
Redirect::to('/items/' . $edited_item->item_id, array('message' => 'Item successfully edited'));
}
}
示例3: voteAction
public function voteAction()
{
$item_id = $this->getRequest()->getParam('item');
$ip = $this->getRequest()->getServer('REMOTE_ADDR');
$vote_date = date("Ymd");
$where = "ip='{$ip}' and vote_date={$vote_date}";
$vote_log = new Vote_log();
$res = $vote_log->fetchAll($where)->toArray();
if (count($res) > 0) {
$this->render('error');
} else {
$date = array("ip" => $ip, "vote_date" => $vote_date, "item_id" => $item_id);
if ($vote_log->insert($date) > 0) {
$itemModel = new Item();
$item = $itemModel->find($item_id)->toArray();
$newcount = $item[0]['vote_count'] + 1;
$set = array("vote_count" => $newcount);
$where = "id={$item_id}";
$itemModel->update($set, $where);
$this->render('ok');
}
}
}
示例4: foreach
function _render_all_pages()
{
foreach ($this->datastore->items as $item) {
$item_to_render = new Item($item);
$item_to_render->_set_full_item($this->datastore->o_get_full_item($item->id));
$item_to_render->render();
$item_to_render->update();
}
}
示例5: getContent
public function getContent()
{
$output = '';
$errors = array();
$id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
$languages = Language::getLanguages(false);
if (Tools::getValue('confirm_msg')) {
$this->context->smarty->assign('confirmation', Tools::getValue('confirm_msg'));
}
if (Tools::isSubmit('submitnewItem')) {
$id_item = (int) Tools::getValue('item_id');
if ($id_item && Validate::isUnsignedId($id_item)) {
$new_item = new Item($id_item);
} else {
$new_item = new Item();
}
$new_item->id_block = Tools::getValue('block_id');
$new_item->type = Tools::getValue('linktype');
$new_item->active = (int) Tools::getValue('active');
$itemtitle_set = false;
foreach ($languages as $language) {
$item_title = Tools::getValue('item_title_' . $language['id_lang']);
if (strlen($item_title) > 0) {
$itemtitle_set = true;
}
$new_item->title[$language['id_lang']] = $item_title;
}
if (!$itemtitle_set) {
$lang_title = Language::getLanguage($this->context->language->id);
if ($new_item->type == 'img') {
$errors[] = 'This Alt text field is required at least in ' . $lang_title['name'];
} else {
$errors[] = 'This item title field is required at least in ' . $lang_title['name'];
}
}
$new_item->class = Tools::getValue('custom_class');
if ($new_item->type == 'link') {
$new_item->icon = Tools::getValue('item_icon');
$new_item->link = Tools::getValue('link_value');
} elseif ($new_item->type == 'img') {
if (isset($_FILES['item_img']) && strlen($_FILES['item_img']['name']) > 0) {
if (!($img_file = $this->moveUploadedImage($_FILES['item_img']))) {
$errors[] = 'An error occurred during the image upload.';
} else {
$new_item->icon = $img_file;
if (Tools::getValue('old_img') != '') {
$filename = Tools::getValue('old_img');
if (file_exists(dirname(__FILE__) . '/img/' . $filename)) {
@unlink(dirname(__FILE__) . '/img/' . $filename);
}
}
}
} else {
$new_item->icon = Tools::getValue('old_img');
}
$new_item->link = Tools::getValue('link_value');
} elseif ($new_item->type == 'html') {
foreach ($languages as $language) {
$new_item->text[$language['id_lang']] = Tools::getValue('item_html_' . $language['id_lang']);
}
}
if (!count($errors)) {
if ($id_item && Validate::isUnsignedId($id_item)) {
if (!$new_item->update()) {
$errors[] = 'An error occurred while update data.';
}
} else {
if (!$new_item->add()) {
$errors[] = 'An error occurred while saving data.';
}
}
if (!count($errors)) {
if ($id_item && Validate::isUnsignedId($id_item)) {
$this->context->smarty->assign('confirmation', $this->l('Item successfully updated.'));
} else {
$confirm_msg = $this->l('New item successfully added.');
Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('topmenu.tpl'));
Tools::redirectAdmin(AdminController::$currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&confirm_msg=' . $confirm_msg);
}
}
}
} elseif (Tools::isSubmit('submit_del_item')) {
$item_id = Tools::getValue('item_id');
if ($item_id && Validate::isUnsignedId($item_id)) {
$subs = $this->getSupMenu($item_id);
$del = true;
if ($subs && count($subs) > 0) {
}
foreach ($subs as $sub) {
$del &= $this->deleteSub($sub['id_sub']);
}
$item = new Item($item_id);
if (!$item->delete() || !$del) {
$errors[] = 'An error occurred while delete item.';
} else {
Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('topmenu.tpl'));
$this->context->smarty->assign('confirmation', $this->l('Delete successful.'));
}
}
} elseif (Tools::isSubmit('submitnewsub')) {
//.........这里部分代码省略.........
示例6: add_item
protected function add_item()
{
if (empty($_POST['id']) || empty($_POST['view'])) {
return false;
}
$item = new Item(null);
$item->update('view', $_POST['view'], 'View', $_POST['id']);
header('Location: ' . Config::instance()->get('baseurl') . '/admin/single?id=' . $_POST['id']);
die;
}
示例7: foreach
$num = 0;
// if(empty($_FILES['images']['name'])){
// echo 'empty';
// }else{
// echo "not empty";
// }
// exit;
if ($_FILES['images']['name'][0] != '') {
foreach ($_FILES['images']['name'] as $file) {
upload('images', $num, 'items');
$num++;
}
}
//exit;
$state = false;
if ($item->update($data, $_POST['old'])) {
$state = true;
unset($_POST);
}
}
include 'templates/header.php';
include 'templates/sidemenu.php';
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Add vendor Item
<small>Add New vendor Items to the system</small>
示例8: isset
$id = isset($_POST['id']) ? $_POST['id'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$description = isset($_POST['description']) ? $_POST['description'] : null;
//Gets array of display
$count = 0;
$zero = false;
$label = $_POST['label'];
if (!$id) {
$file = isset($_FILES['file']) ? $_FILES['file'] : null;
$fileUploader = new FileUploader($file, $name, $description);
$fileId = $fileUploader->uploadFile();
$item = new Item($name, $description, true);
$id = $item->create();
} else {
$item = new Item($name, $description, true, $id);
$item->update();
}
//Gets array of tags
$tags = $_POST['tags'];
//Gets array of categories
$categories = $_POST['categories'];
$db = new Database();
$db->connect();
//CATEGORIES
$db->select("category_connector", "category_id", null, "item_id=" . $id);
$existingCategories = array_column($db->getResult(), 'category_id');
//GET ALL Grandparent Cats
$db->select("categories", "id", null, "parent_id = 0");
$grandparentCats = array_column($db->getResult(), 'id');
foreach ($categories as $key => $categoryId) {
$pos = array_search($categoryId, $existingCategories);
示例9: testUpdate
function testUpdate()
{
//Arrange
$description = "Pliny the Elder";
$cost = 5.0;
$id = null;
$test_item = new Item($description, $cost, $id);
$test_item->save();
$new_description = "Pliny the Younger";
$new_cost = 10.0;
//Act
$test_item->update($new_description, $new_cost);
//Assert
$this->assertEquals($new_description, $test_item->getDescription());
$this->assertEquals($new_cost, $test_item->getCost());
}
示例10: editTimeAndDate
public function editTimeAndDate()
{
$this->load->library('jdf');
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library("session");
if ($this->form_validation->run('item/editTimeAndDate') === FALSE) {
$this->load->view("templates/errorForm.php", array("fields" => array('id', 'date', 'endTime', 'startTime')));
} else {
$item = new Item($this->input->post("id"));
if ($item->getUserId() != $this->session->getStudentId()) {
echo "->IAMHERE at <b>" . __FUNCTION__ . "</b> at <b>" . __FILE__ . "</b> at <b>" . __LINE__ . "</b><br>" . PHP_EOL;
echo "->DEBUG at <b>" . __FUNCTION__ . "</b>at <b>" . __LINE__ . '</b>$item->user_id = ' . $item->getUserId() . "<br>" . PHP_EOL;
echo "->DEBUG at <b>" . __FUNCTION__ . "</b>at <b>" . __LINE__ . '</b>$this->session->getStudentId() = ' . $this->session->getStudentId() . "<br>" . PHP_EOL;
echo "->DEBUG at <b>" . __FUNCTION__ . "</b>at <b>" . __LINE__ . '</b>$item->user_id == $this->session->getStudentId() = ' . $item->user_id == $this->session->getStudentId() . "<br>";
return;
}
$start = makeTime($this->input->post("date"), $this->input->post("startTime"));
$end = makeTime($this->input->post("date"), $this->input->post("endTime"));
try {
$item->setStartEnd($start, $end);
$item->update();
$this->load->view("item/item_created.php", array("item" => $this->setFormat(array($item))));
} catch (Item_Overlap_With_Other_Item $e) {
$this->load->view("item/item_error.php");
echo "->IAMHERE at <b>" . __FUNCTION__ . "</b> at <b>" . __FILE__ . "</b> at <b>" . __LINE__ . "</b><br>";
Item_Error::Item_Overlap_With_Other_Item();
} catch (Item_Create_With_Zero_Duration $e) {
$this->load->view("item/item_error.php");
echo "->IAMHERE at <b>" . __FUNCTION__ . "</b> at <b>" . __FILE__ . "</b> at <b>" . __LINE__ . "</b><br>";
Item_Error::Item_Create_With_Zero_Duration();
} catch (Item_Start_Greater_Than_End_Exception $e) {
$this->load->view("item/item_error.php");
echo "->IAMHERE at <b>" . __FUNCTION__ . "</b> at <b>" . __FILE__ . "</b> at <b>" . __LINE__ . "</b><br>";
Item_Error::Item_Start_Greater_Than_End_Exception();
}
}
}
示例11: PageContent
include "../inc/classes/Category.php";
include "../inc/classes/Helpers.php";
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'sort') {
$objItem = new Item();
$objItem->SortValues(substr($_REQUEST['action'], 1), substr($_REQUEST['action'], 0, 1));
unset($objItem);
} elseif (isset($_REQUEST['dragsort'])) {
// handle drag sort ajax request:
$objItem = new Item($_REQUEST['id']);
$new_sort_order = $_REQUEST['idx'] * 10 + 5;
if ($new_sort_order > $objItem->SortOrder) {
$new_sort_order += 10;
// increasing sort order so must add another 10
}
$objItem->SortOrder = $new_sort_order;
$objItem->update();
echo "success";
exit;
// just exit since this is an ajax request
}
$category = new Category($_REQUEST['cat']);
include "includes/pagetemplate.php";
function PageContent()
{
global $category;
?>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
示例12: saveItem
public function saveItem($id, $price, $name, $categoryID, $units, $amount)
{
$db = $this->db;
$newItem = new Item();
$newItem->Name = $name;
$newItem->Price = $price;
$newItem->Units = $units;
$newItem->Amount = $amount;
$newItem->CategoryID = $categoryID;
if (0 != $id) {
$newItem->ID = $id;
$newItem->update($db);
} else {
$newItem->save($db);
}
}
示例13: header
$obj->BackgroundColor = $_REQUEST["background_color"];
$obj->ContactEmail = $_REQUEST["contact_email"];
$obj->GalleryDescription = $_REQUEST["gallery_description"];
$obj->create();
// redirect to listing list
header("Location:item_list.php?cat=" . $_REQUEST['category_id']);
exit;
} else {
// update
$obj = new Item($_REQUEST["id"]);
$obj->CategoryId = $_REQUEST["category_id"];
$obj->ItemName = $_REQUEST["item_name"];
$obj->BackgroundColor = $_REQUEST["background_color"];
$obj->ContactEmail = $_REQUEST["contact_email"];
$obj->GalleryDescription = $_REQUEST["gallery_description"];
$obj->update();
// redirect to listing list
header("Location:item_list.php?cat=" . $_REQUEST['category_id']);
exit;
}
} else {
if ($_REQUEST['mode'] == 'e') {
//listing
$obj = new Item($id);
$id = $obj->Id;
$category_id = $obj->CategoryId;
$item_name = $obj->ItemName;
$background_color = $obj->BackgroundColor;
$contact_email = $obj->ContactEmail;
$gallery_description = $obj->GalleryDescription;
$category = new Category($category_id);