本文整理匯總了PHP中ItemManager::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP ItemManager::create方法的具體用法?PHP ItemManager::create怎麽用?PHP ItemManager::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ItemManager
的用法示例。
在下文中一共展示了ItemManager::create方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: intval
<?php
if (isset($_POST['action'])) {
if ($_POST['action'] == "add") {
if (isset($_POST['name'], $_POST['category'], $_POST['short_descr'], $_POST['image'], $_POST['description'], $_POST['price'], $_POST['stock'])) {
$id_category = intval($_POST['category']);
$itemManager = new ItemManager($database);
$subcategoryManager = new SubcategoryManager($database);
$subcategory = $subcategoryManager->findById($id_category);
$photo_itemManager = new Photo_itemManager($database);
try {
$item = $itemManager->create($subcategory, $_POST['name'], $_POST['description'], $_POST['short_descr'], $_POST['price'], $_POST['stock']);
} catch (Exception $e) {
$_SESSION['errors'] = $e->getMessage();
}
if (!isset($_SESSION['errors']) || $_SESSION['errors'] == "") {
try {
$photo = $photo_itemManager->add($item, $currentUser, $_POST['image']);
} catch (Exception $e) {
$itemManager->delete($item);
$_SESSION['errors'] = $e->getMessage();
}
if (!isset($_SESSION['errors']) || $_SESSION['errors'] == "") {
$_SESSION['success'] = "Produit a bien été :)";
header('Location: ?page=item&id=' . $item->getId());
exit;
}
}
}
}
}
示例2: testCopy
/**
* Client
*/
function testCopy(ItemManager $manager, $item_code)
{
/**
* 商品のインスタンスを2つ作成
*/
$item1 = $manager->create($item_code);
$item2 = $manager->create($item_code);
/**
* 1つだけコメントを削除
*/
$item2->getDetail()->comment = 'コメントを書き換えました';
/**
* 商品情報を表示
* 深いコピーをした場合、$item2への変更は$item1に影響しない
*/
echo '■オリジナル';
$item1->dumpData();
echo '■コピー';
$item2->dumpData();
echo '<hr>';
}
示例3: ItemManager
<?php
if (isset($_SESSION['id']) && $currentUser->getStatus() > 0) {
// Categories admin page
if ($_GET['page'] == 'dashboard_items') {
// Create new category
if (isset($_POST['new_name'], $_POST['new_category'], $_POST['new_price'], $_POST['new_stock'], $_POST['new_image'], $_POST['new_description'])) {
$itemManager = new ItemManager($db);
$categoryManager = new CategoryManager($db);
try {
$category = $categoryManager->readById($_POST['new_category']);
$item = $itemManager->create($category, $_POST['new_name'], $_POST['new_price'], $_POST['new_stock'], $_POST['new_image'], $_POST['new_description']);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
if (count($errors) == 0) {
header('Location: ?page=dashboard_items');
exit;
}
}
}
}