本文整理汇总了PHP中app\models\Categories::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Categories::update方法的具体用法?PHP Categories::update怎么用?PHP Categories::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Categories
的用法示例。
在下文中一共展示了Categories::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public static function edit($id)
{
if (!Request::is_admin()) {
Response::redirect('');
}
if ("POST" == Request::method()) {
$id = Request::POST()->id;
$name = Request::POST()->name;
$decsription = Request::POST()->description;
Categories::update($id, $name, $decsription);
# push flash-message
Session::push('flash-message', 'That category has changed successfuly!');
Response::redirect('categories');
} else {
$category = Categories::findByPK($id);
$categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
View::render('categories/add', ['category' => $category, 'categories' => $categories]);
}
}
示例2: newCategory
public function newCategory($id)
{
if ($_POST) {
$request = (object) $_POST;
$category = new Categories();
if (isset($id)) {
$category->update($id, $request->nombre, $request->descripcion);
newFlashMessage('test', 'Categoria ' . ucwords($request->nombre) . " actualizada.");
return redirect('admin/category');
} else {
$category->create($request->nombre, $request->descripcion);
newFlashMessage('test', 'Categoria ' . ucwords($request->nombre) . " creada.");
return redirect('admin/category/');
}
} elseif (isset($id)) {
$categories = new Categories();
$category = $categories->find($id);
return view('admin/categories/update', compact('category'), 'baseAdmin');
} else {
return view('admin/categories/create', '', 'baseAdmin');
}
}