本文整理汇总了PHP中MenuItem::instantiate方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::instantiate方法的具体用法?PHP MenuItem::instantiate怎么用?PHP MenuItem::instantiate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::instantiate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
require_once '../includes/functions.php';
require 'templates/header.php';
$header = "menu";
$page = "edit";
require 'templates/navbar.php';
require 'templates/sidebar.php';
$alert = array();
if (isset($_POST['submit'])) {
$menu_item = new MenuItem();
$menu_item->instantiate($_POST);
if (isset($_POST['halfs'])) {
$menu_item->halfs = true;
} else {
$menu_item->halfs = false;
}
if ($menu_item->update()) {
redirect_to('menu.view.php?success=edit');
} else {
redirect_to('menu.view.php?error=edit');
}
}
if (isset($_GET['id'])) {
$id = intval($_GET['id']);
$menu_item = MenuItem::select(array('id' => $id));
if (!is_object($menu_item)) {
redirect_to('menu.view.php');
}
?>
<div class="row" style="margin-right: 0">
示例2: array
<?php
require_once '../includes/functions.php';
require 'templates/header.php';
$header = "menu";
$page = "add";
require 'templates/navbar.php';
require 'templates/sidebar.php';
$alert = array();
if (isset($_POST['submit'])) {
$menu = new MenuItem();
$menu->instantiate($_POST);
if (!empty($menu->halfs)) {
$menu->halfs = '1';
}
if ($menu->category_id == "#add") {
$menuCat = new MenuItemCategory();
$menuCat->name = $_POST['menuCategory'];
$menuCat->insert();
$menu->category_id = $menuCat->id;
}
if ($menu->insert()) {
$alert['success'] = "The menu item has been added!";
} else {
$alert['error'] = "The menu item could not be added!";
}
}
?>
<div class="row" style="margin-right: 0">
<div class="col-md-6 col-md-offset-3 page-wrapper">