当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::update方法代码示例

本文整理汇总了PHP中Category::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::update方法的具体用法?PHP Category::update怎么用?PHP Category::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category的用法示例。


在下文中一共展示了Category::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $val = $this->contactRepository->getCreateForm();
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     $contact = $this->contactRepository->getFirst();
     if ($contact) {
         if (!$this->contactRepository->update($contact->id, $val->getInputData())) {
             return Redirect::back()->with('errors', $this->contactRepository->errors())->withInput();
         }
     } else {
         if (!$this->contactRepository->create($val->getInputData())) {
             return Redirect::back()->with('errors', $this->contactRepository->errors())->withInput();
         }
     }
     return Redirect::action('AdminContactsController@index')->with('success', 'Saved');
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:23,代码来源:AdminContactsController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $this->categoryRepository->findById($id);
     $val = $this->categoryRepository->getEditForm($id);
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     if (!$this->categoryRepository->update($id, $val->getInputData())) {
         return Redirect::back()->with('errors', $this->categoryRepository->errors())->withInput();
     }
     return Redirect::action('AdminCategoriesController@index')->with('success', 'Updated');
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:18,代码来源:AdminCategoriesController.php

示例3: testUpdate

 function testUpdate()
 {
     //Arrange
     $name = "Work stuff";
     $id = 1;
     $test_category = new Category($name, $id);
     $test_category->save();
     $new_name = "Home stuff";
     //Act
     $test_category->update($new_name);
     //Assert
     $this->assertEquals("Home stuff", $test_category->getName());
 }
开发者ID:jtorrespdx,项目名称:to_do,代码行数:13,代码来源:CategoryTest.php

示例4: update

 public static function update($categoryId)
 {
     $params = $_POST;
     $categoryAttributes = array('name' => $params['name'], 'id' => $categoryId);
     $category = new Category($categoryAttributes);
     $categoryErrors = $category->errors();
     if (count($categoryErrors) == 0) {
         $category->update();
         Redirect::to('/category', array('message' => 'Luokkaa muokattu onnistuneesti.'));
     } else {
         View::make('/reminders/edit_category.html', array('categoryErrors' => $categoryErrors, 'category' => $categoryAttributes));
     }
 }
开发者ID:smre,项目名称:Tsoha-Bootstrap,代码行数:13,代码来源:class_controller.php

示例5: actionModified

 /**
  * 添加、修改分类结果
  */
 public function actionModified()
 {
     $Category = new Category();
     $data = WaveCommon::getFilter($_POST);
     $cid = (int) $data['cid'];
     unset($data['cid']);
     if ($cid == 0) {
         $Category->insert($data);
     } else {
         $Category->update($data, array('cid' => $cid));
     }
     $this->jumpBox('成功!', Wave::app()->homeUrl . 'categories', 1);
 }
开发者ID:xpmozong,项目名称:wavephp2_demos,代码行数:16,代码来源:CategoriesController.php

示例6: init

 function init()
 {
     $obj = new Category();
     $func = array_shift($this->param);
     $id = array_shift($this->param);
     if ($func != '') {
         $_SERVER['REQUEST_METHOD'] = 'POST';
         switch ($func) {
             case 'add':
                 $data['parent_id'] = $id;
                 $data['name'] = $_POST['name'];
                 $data['active'] = true;
                 try {
                     $obj->add($data);
                 } catch (Exception $e) {
                 }
                 header('Location: /admin_categories');
                 exit;
                 break;
             case 'save':
                 $data['name'] = $_POST['name'];
                 try {
                     $obj->update($id, $data);
                 } catch (Exception $e) {
                 }
                 header('Location: /admin_categories');
                 exit;
                 break;
             case 'delete':
                 try {
                     $obj->delete($id);
                 } catch (Exception $e) {
                 }
                 header('Location: /admin_categories');
                 exit;
                 break;
             case 'activate':
                 try {
                     $obj->invert($id);
                 } catch (Exception $e) {
                 }
                 header('Location: /admin_categories');
                 exit;
                 break;
         }
     }
 }
开发者ID:jedaika,项目名称:Trainings,代码行数:47,代码来源:admin_categories.php

示例7: update

 public function update()
 {
     $Category = new Category($this->db, $this->plural_resorce);
     if ($_POST['edited_categoryname'] != '') {
         $Category = new Category($this->db, $this->plural_resorce);
         $sql = $Category->update();
         mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
     }
     if (isset($_POST['category_id'])) {
         $param = $_POST['category_id'];
         header("Location: ../task/index?category_id={$param}");
         exit;
     } else {
         header('Location: ../task/index');
         exit;
     }
 }
开发者ID:hiroki0325,项目名称:geechscamp,代码行数:17,代码来源:categories_contllorer.php

示例8: createOrUpdateAttribute

 public function createOrUpdateAttribute($attrs)
 {
     return;
     $fromto = array('term_id' => 'term_id', 'name' => 'name', 'slug' => 'slug', 'term_group' => 'group_id', 'term_taxonomy_id' => 'taxonomy_id', 'description' => 'description', 'parent' => 'parent_id', 'count' => 'count');
     $new_attrs = array();
     foreach ($fromto as $key => $nkey) {
         if (isset($attrs[$key])) {
             $new_attrs[$nkey] = $attrs[$key];
         }
     }
     $cat = new Category();
     if (isset($new_attrs['id']) && !empty($new_attrs['id'])) {
         $cat->update($new_attrs);
     } else {
         $cat->create($new_attrs);
     }
 }
开发者ID:borisdiakur,项目名称:woocommerce-json-api,代码行数:17,代码来源:ProductAttribute.php

示例9: Session

<?php

require_once '../model/paths.php';
$session = new Session();
if (!$session->isLogin) {
    redirect("../login.php");
}
$database = new Database();
$user = new User();
$category = new Category();
if ($_POST['category']) {
    $category->setCategoryId($database->escapeString($_POST['categoryId']));
    foreach ($_POST as $key => $value) {
        if ($key == "categoryId" || $key == "submit") {
            continue;
        }
        $category->update($database, $key, $value);
    }
    redirect("../posts.php?posts=4&category={$_POST['categoryId']}");
} else {
    echo "<h2>Problem in editing category. Try again later or contact your administrator.</h2>";
}
开发者ID:jetmirhaxhisefa,项目名称:rezervime,代码行数:22,代码来源:editCategory.php

示例10: finish_installation

function finish_installation($password)
{
    require_once LIB_PATH . 'osclass/model/Admin.php';
    require_once LIB_PATH . 'osclass/model/Category.php';
    require_once LIB_PATH . 'osclass/model/Item.php';
    require_once LIB_PATH . 'osclass/helpers/hPlugins.php';
    require_once LIB_PATH . 'osclass/compatibility.php';
    require_once LIB_PATH . 'osclass/plugins.php';
    $data = array();
    $mAdmin = new Admin();
    $mPreference = Preference::newInstance();
    $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'osclass_installed', 's_value' => '1', 'e_type' => 'BOOLEAN'));
    // update categories
    $mCategories = new Category();
    if (Params::getParam('submit') != '') {
        $categories = Params::getParam('categories');
        if (is_array($categories)) {
            foreach ($categories as $category_id) {
                $mCategories->update(array('b_enabled' => '1'), array('pk_i_id' => $category_id));
            }
        }
    }
    $aCategoriesToDelete = $mCategories->listWhere("a.b_enabled = 0");
    foreach ($aCategoriesToDelete as $aCategory) {
        $mCategories->deleteByPrimaryKey($aCategory['pk_i_id']);
    }
    $admin = $mAdmin->findByPrimaryKey(1);
    $data['s_email'] = $admin['s_email'];
    $data['admin_user'] = $admin['s_username'];
    $data['password'] = $password;
    return $data;
}
开发者ID:randomecho,项目名称:OSClass,代码行数:32,代码来源:install-functions.php

示例11: controlCategoriesForActivateTheir

 /**
  * Controls and changes, if possible, category's active parameter if a product's active parameter changes.
  * 
  * @param array $ids_categories_array
  * @return 
  *
  */
 private function controlCategoriesForActivateTheir($ids_categories_array)
 {
     $size_array_categories = sizeof($ids_categories_array);
     for ($i = 0; $i < $size_array_categories; $i++) {
         $tmp = $ids_categories_array[$i];
         $category = new Category((int) $tmp["id"]);
         $array_of_ids_products = $category->getProductsWs();
         $size_array_products = sizeof($array_of_ids_products);
         $count = 0;
         for ($j = 0; $j < $size_array_products; $j++) {
             $array_prod = $array_of_ids_products[$j];
             $product = new Product((int) $array_prod["id"]);
             if (!$product->active) {
                 $count++;
             }
         }
         if ($count == $size_array_products) {
             $category->active = 0;
             $category->update();
         } else {
             $category->active = 1;
             $category->update();
         }
     }
 }
开发者ID:valucifer,项目名称:S-SoldP-Pal,代码行数:32,代码来源:PrestashopProducts.php

示例12: finish_installation

function finish_installation()
{
    require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
    require_once LIB_PATH . 'osclass/model/Admin.php';
    require_once LIB_PATH . 'osclass/model/Preference.php';
    require_once LIB_PATH . 'osclass/model/Category.php';
    require_once LIB_PATH . 'osclass/model/Item.php';
    require_once LIB_PATH . 'osclass/core/Params.php';
    require_once LIB_PATH . 'osclass/compatibility.php';
    require_once LIB_PATH . 'osclass/utils.php';
    $data = array();
    $password = osc_genRandomPassword();
    $mAdmin = new Admin();
    $admin_user = 'admin';
    $admin = $mAdmin->update(array('s_password' => sha1($password)), array('s_username' => $admin_user));
    $mPreference = Preference::newInstance();
    $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'osclass_installed', 's_value' => '1', 'e_type' => 'BOOLEAN'));
    // update categories
    $mCategories = new Category();
    if (Params::getParam('submit') != '') {
        $categories = Params::getParam('categories');
        if (is_array($categories)) {
            foreach ($categories as $category_id) {
                $mCategories->update(array('b_enabled' => '1'), array('pk_i_id' => $category_id));
            }
        }
    }
    $aCategoriesToDelete = $mCategories->listWhere("a.b_enabled = 0");
    foreach ($aCategoriesToDelete as $aCategory) {
        $mCategories->deleteByPrimaryKey($aCategory['pk_i_id']);
    }
    $admin = $mAdmin->findByPrimaryKey(1);
    $data['s_email'] = $admin['s_email'];
    $data['admin_user'] = $admin_user;
    $data['password'] = $password;
    $body = 'Welcome ' . $mPreference->get('pageTitle') . ',<br/><br/>';
    $body .= 'Your OSClass installation at ' . WEB_PATH . ' is up and running. You can access to the administration panel with this data access:<br/>';
    $body .= '<ul>';
    $body .= '<li>username: ' . $admin_user . '</li>';
    $body .= '<li>password: ' . $password . '</li>';
    $body .= '</ul>';
    $body .= 'Regards,<br/>';
    $body .= 'The <a href=\'http://osclass.org/\'>OSClass</a> team';
    $sitename = strtolower($_SERVER['SERVER_NAME']);
    if (substr($sitename, 0, 4) == 'www.') {
        $sitename = substr($sitename, 4);
    }
    require_once LIB_PATH . 'phpmailer/class.phpmailer.php';
    $mail = new PHPMailer();
    $mail->CharSet = "utf-8";
    $mail->Host = "localhost";
    $mail->From = 'osclass@' . $sitename;
    $mail->FromName = 'OSClass';
    $mail->Subject = 'OSClass successfully installed!';
    $mail->AddAddress($admin['s_email'], 'OSClass administrator');
    $mail->Body = $body;
    $mail->AltBody = $body;
    if (!$mail->Send()) {
        echo $mail->ErrorInfo;
    }
    return $data;
}
开发者ID:hashemgamal,项目名称:OSClass,代码行数:62,代码来源:install-functions.php

示例13: Category

 function test_update()
 {
     //arrange
     $name = "Business";
     $id = null;
     $test_category = new Category($name, $id);
     $test_category->save();
     $new_name = "Personal";
     //act
     $test_category->update($new_name);
     //assert
     $this->assertEquals("Personal", $test_category->getName());
 }
开发者ID:julianstewart,项目名称:address_book,代码行数:13,代码来源:CategoryTest.php

示例14:

echo "<div class='right-button-margin'>";
echo "<a href='read_categories.php' class='btn btn-primary pull-right'>";
echo "<span class='glyphicon glyphicon-list'></span> Read Categories";
echo "</a>";
echo "</div>";
// set ID property of product to be edited
$category->id = $category_id;
// read the details of category to be edited
$category->readOne();
// if the form was submitted
if ($_POST) {
    // set category property values
    $category->name = $_POST['name'];
    $category->description = $_POST['description'];
    // update the category
    if ($category->update()) {
        echo "<div class=\"alert alert-success alert-dismissable\">";
        echo "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>";
        echo "Category was updated.";
        echo "</div>";
    } else {
        echo "<div class=\"alert alert-danger alert-dismissable\">";
        echo "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>";
        echo "Unable to update category.";
        echo "</div>";
    }
}
?>
	
<!-- HTML form for updating a product -->
<form action='update_category.php?id=<?php 
开发者ID:marwyre,项目名称:e-commerce,代码行数:31,代码来源:update_category.php

示例15: header

switch ($method) {
    case 'insert':
        if (isset($_POST['add_cat']) && !empty($_POST['add_cat'])) {
            $cat->name = $_POST['add_cat'];
            $cat->insert();
            header("location:../controle.php");
        } else {
            $_SESSTION['error'] = "please enter a valid name";
            header("location:../controle.php");
        }
        # code...
        break;
    case 'edit':
        if (isset($_POST['edit_cat']) && !empty($_POST['edit_cat'])) {
            $cat->name = $_POST['edit_cat'];
            $cat->update($id);
            echo "id=" . $id . " , name = " . $_POST['edit_cat'];
            header("location:../controle.php");
        } else {
            $_SESSTION['error'] = "please enter a valid name";
            echo "error";
            header("location:../controle.php");
        }
        # code...
        break;
    case 'delete':
        $cat->delete($id);
        header("location:../controle.php");
        # code...
        break;
    default:
开发者ID:ElsayedAhmed,项目名称:php-proj,代码行数:31,代码来源:server.php


注:本文中的Category::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。