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


PHP Category::insert方法代码示例

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


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

示例1: addAction

 /**
  * Allows a user to add a workshop category
  *
  */
 public function addAction()
 {
     $messages = array();
     $category = new Category();
     $form = $category->form();
     if ($this->_request->isPost()) {
         if ($form->isValid($_POST)) {
             $data = array('name' => $form->getValue('name'), 'description' => $form->getValue('description'));
             $categoryId = $category->insert($data);
             $trigger = new Ot_Trigger();
             $data['accountId'] = Zend_Auth::getInstance()->getIdentity()->accountId;
             $trigger->setVariables($data);
             $trigger->dispatch('Category_Add');
             $this->_helper->flashMessenger->addMessage('msg-info-categoryAdded');
             $this->_helper->redirector->gotoUrl('/workshop/category/details/?categoryId=' . $categoryId);
         } else {
             $messages[] = "msg-error-formSubmitProblem";
         }
     }
     $this->view->messages = $messages;
     $this->view->form = $form;
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.wysiwyg.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.wysiwyg.css');
     $this->_helper->pageTitle('workshop-category-add:title');
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:29,代码来源:CategoryController.php

示例2: 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

示例3: create

 /**
  * Create new Category
  */
 public function create()
 {
     if ($this->slim->request->isGet()) {
         $this->slim->render('category/create.html.twig', ['sessionUser' => $this->getSessionUser()]);
     } elseif ($this->slim->request->isPost()) {
         $name = $_POST['name'];
         $newCategory = new Category($this->slim->db);
         $newCategory->setName($name);
         $newCategory->insert();
         $this->slim->flash('success', 'Category created');
         $this->slim->redirect('/categories');
     }
 }
开发者ID:lagut-in,项目名称:Slim-Image-Archive,代码行数:16,代码来源:CategoryController.php

示例4: action

 function action()
 {
     // 子类
     $category = new Category();
     $kdgs = new Kdgs();
     $story_url = new StoryUrl();
     $current_time = date('Y-m-d H:i:s');
     $parent_category_list = $kdgs->get_parent_category($this->home_url);
     foreach ($parent_category_list as $k => $v) {
         $exists = $category->check_exists("`res_name`='kdgs' and `s_id`='{$v['s_id']}'");
         if ($exists) {
             continue;
         } else {
             $category_id = $category->insert(array('res_name' => 'kdgs', 'parent_id' => 0, 'title' => $v['title'], 's_id' => $v['s_id'], 's_p_id' => 0, 'from_url' => $this->home_url, 'link_url' => $v['link_url'], 's_cover' => $v['cover'], 'add_time' => date('Y-m-d H:i:s')));
             $story_url->insert(array('res_name' => 'category', 'res_id' => $category_id, 'field_name' => 'cover', 'source_url' => $v['cover'], 'source_file_name' => ltrim(strrchr($v['cover'], '/'), '/'), 'add_time' => date('Y-m-d H:i:s')));
             echo $category_id;
             echo "<br />";
         }
     }
     // 子类
     $category_list = $category->get_list("`res_name`='kdgs' and `s_p_id`=0");
     foreach ($category_list as $k => $v) {
         $children_category_list = $kdgs->get_children_category_list($v['link_url']);
         foreach ($children_category_list as $k2 => $v2) {
             $exists = $category->check_exists("`res_name`='kdgs' and `s_id`='0' and `s_p_id`='{$v2['s_p_id']}'");
             if ($exists) {
                 continue;
             } else {
                 $category_id = $category->insert(array('res_name' => 'kdgs', 'parent_id' => $v['id'], 'title' => $v2['title'], 's_id' => 0, 's_p_id' => $v2['s_p_id'], 'from_url' => $v['link_url'], 'link_url' => $v2['link_url'], 's_cover' => $v2['cover'], 'add_time' => date('Y-m-d H:i:s')));
                 $story_url->insert(array('res_name' => 'category', 'res_id' => $category_id, 'field_name' => 'cover', 'source_url' => $v2['cover'], 'source_file_name' => ltrim(strrchr($v2['cover'], '/'), '/'), 'add_time' => date('Y-m-d H:i:s')));
                 echo "children:" . $category_id;
                 echo "<br />";
             }
         }
     }
 }
开发者ID:huqq1987,项目名称:clone-lemon,代码行数:36,代码来源:kdgs_category.php

示例5: run

 public function run()
 {
     $date = new DateTime();
     $category[] = array('name' => 'Laptops', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     $date = new DateTime();
     $category[] = array('name' => 'Desktops', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     $date = new DateTime();
     $category[] = array('name' => 'Tablets', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     $date = new DateTime();
     $category[] = array('name' => 'Phones', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     $date = new DateTime();
     $category[] = array('name' => 'Monitors', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     // Delete all the blog posts
     DB::table('categories')->truncate();
     // Insert the blog posts
     Category::insert($category);
 }
开发者ID:naiwungmusic,项目名称:snipe-it,代码行数:17,代码来源:CategoriesSeeder.php

示例6: Category

<?php

///////////////////////////////////
require 'tables.php';
if (isset($_GET['categoryName'])) {
    $category_new = $_GET['categoryName'];
    $Categorys = new Category();
    $Categorys->categoryName = $category_new;
    $Categorys->insert();
}
$Categorys = new Category();
$data = $Categorys->select();
$response = json_encode($data);
echo $response;
开发者ID:smagdy,项目名称:PHPproject,代码行数:14,代码来源:allCategory.php

示例7: Category

session_start();
include 'cat.php';
$cat = new Category();
if (isset($_GET['method'])) {
    $method = $_GET['method'];
} else {
    $method = $_POST['method'];
}
if (isset($_GET['id'])) {
    $id = $_GET['id'];
}
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':
        # code...
        break;
    case 'delete':
        $cat->delete($id);
        header("location:../controle.php");
        # code...
        break;
开发者ID:ElsayedAhmed,项目名称:php-proj,代码行数:31,代码来源:server.php

示例8: __set

	private $id;
	private $name;
	private $content;
	private $cid;
	
	public function __set($name, $value) {
		$this->name = $value;
	}
	
	public function __get($name) {
		return $this->$name;
	}
	
	public function insert($row) {
		$sql = "insert into think_category values(null, '$this->name'.'$this->content'.'$this->cid')";
		mysql_query ( $sql );
	}
	
	public function delete() {
		$sql = "delete from think_category where id='$this->id'";
		mysql_query ( $sql );
	}
}

$cate=new Category();
$cate->name='电话';
$cate->content = '很好';
$cate->cid = '1';
$cate->insert();

开发者ID:uhgy,项目名称:phppractice,代码行数:29,代码来源:Category.class.php

示例9: Category

<?php

require_once "config.php";
if (isset($_POST['btn_submit'])) {
    $new_cat = new Category();
    $new_cat->name = $_POST['tb_new_cat'];
    $new_cat->insert();
    header("Location: " . SITE_ROOT . "personal");
}
开发者ID:jeffsouln,项目名称:OutdoorSerbia,代码行数:9,代码来源:add_cat.php

示例10: header

if ($action == "save") {
    $insert = TRUE;
    $errMsg = NULL;
    if ($name == "") {
        $errMsg = Text::getText("MissingName");
        $insert = FALSE;
    }
    if ($insert) {
        $existing = Category::getByName($name);
        if ($existing != NULL) {
            $errMsg = Text::getText("AlreadyExists");
            $insert = FALSE;
        }
    }
    if ($insert) {
        $c->insert();
        header("Location: categoryList.php");
        exit;
    } else {
        $buttonCaption = Text::getText("Add");
        include("header.php");
        print "<h2>".Text::getText("AddCategory")."</h2>";
        include("categoryForm.php");
        include("footer.php");
    }
} else {
    $title = Text::getText("AddCategory");
    $buttonCaption = Text::getText("Add");
    include("header.php");
    print "<h2>".Text::getText("AddCategory")."</h2>";
    include("categoryForm.php");
开发者ID:elecnix,项目名称:smellyfish,代码行数:31,代码来源:categoryAdd.php

示例11: newCategory

function newCategory()
{
    $results = array();
    $results['pageTitle'] = "New Article Category";
    $results['formAction'] = "newCategory";
    if (isset($_POST['saveChanges'])) {
        $category = new Category();
        $category->storeFormValues($_POST);
        $category->insert();
        header("Location: admin.php?action=listCategories&status=changesSaved");
    } elseif (isset($_POST['cancel'])) {
        header("Location: admin.php?action=listCategories");
    } else {
        $results['category'] = new Category();
        require TEMPLATE_PATH . "/admin/editCategory.php";
    }
}
开发者ID:kirill2ll,项目名称:Web-Development-Basics,代码行数:17,代码来源:admin.php

示例12: Template_API

include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.user.php";
include_once APP_INC_PATH . "class.project.php";
include_once APP_INC_PATH . "class.category.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "categories");
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
    if ($role_id == User::getRoleID('administrator')) {
        $tpl->assign("show_setup_links", true);
    }
    @($prj_id = $HTTP_POST_VARS["prj_id"] ? $HTTP_POST_VARS["prj_id"] : $HTTP_GET_VARS["prj_id"]);
    $tpl->assign("project", Project::getDetails($prj_id));
    if (@$HTTP_POST_VARS["cat"] == "new") {
        $tpl->assign("result", Category::insert());
    } elseif (@$HTTP_POST_VARS["cat"] == "update") {
        $tpl->assign("result", Category::update());
    } elseif (@$HTTP_POST_VARS["cat"] == "delete") {
        Category::remove();
    }
    if (@$HTTP_GET_VARS["cat"] == "edit") {
        $tpl->assign("info", Category::getDetails($HTTP_GET_VARS["id"]));
    }
    $tpl->assign("list", Category::getList($prj_id));
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
开发者ID:juliogallardo1326,项目名称:proc,代码行数:31,代码来源:categories.php

示例13: unlink

                    unlink($dir . "/" . $object);
                }
            }
        }
        reset($objects);
        rmdir($dir);
    } else {
        unlink($dir);
    }
}
//------------------------------------------------------ insert new category ----------------------------------------------
if (isset($_GET['categoryName'])) {
    if (!empty($_GET['categoryName'])) {
        $category = new Category();
        $category->cName = $_GET['categoryName'];
        $responce = $category->insert();
        if ($responce == 0) {
            $responce = 'this category name already exist';
        } else {
            mkdir('../../images/products/' . $responce, 0777);
            chmod('../../images/products/' . $responce, 0777);
        }
    } else {
        $responce = 'please enter a value';
    }
}
//------------------------------------------------------ delete category ----------------------------------------------
if (isset($_GET['cID'])) {
    if (!empty($_GET['cID'])) {
        $category = new Category();
        $category->delete($_GET['cID']);
开发者ID:SalmaNegm,项目名称:eShop,代码行数:31,代码来源:adminCategory_server.php

示例14: POST

    $idCategory = POST('id');
    ossim_valid($idCategory, OSS_ALPHA, 'illegal:' . _("Category"));
    //
    $nameSubCategory = POST('nameSubCategory');
    ossim_valid($nameSubCategory, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Name Subcategory"));
    if (Subcategory::insert($conn, $idCategory, $nameSubCategory)) {
        // insert ok
        $msg = 'Ok! Add Subcategory';
    } else {
        // fail insert
        $msg = 'Error no add Subcategory';
    }
} elseif ($action == 'addCategory') {
    $nameCategory = POST('nameCategory');
    ossim_valid($nameCategory, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Name Subcategory"));
    if (Category::insert($conn, $nameCategory)) {
        // insert ok
        $msg = 'Ok! Add Category';
    } else {
        // fail insert
        $msg = 'Error no add Category';
    }
} elseif ($action == 'deleteCategory') {
    $idCategory = GET('id');
    ossim_valid($idCategory, OSS_ALPHA, 'illegal:' . _("Category"));
    if (Category::delete($conn, $idCategory)) {
        // insert ok
        $msg = 'Ok! Delete Category';
    } else {
        // fail insert
        $msg = 'Error no delete Category';
开发者ID:jhbsz,项目名称:ossimTest,代码行数:31,代码来源:category.php

示例15: _

                 $data['data'] = _('Subcategory added successfully');
             }
         } else {
             $data['data'] = _('Error! This subcategory already exists');
         }
     } else {
         $data['data'] = ossim_get_error_clean();
     }
 } elseif ($action == 'add_category') {
     $c_name = POST('c_name') != '' ? str_replace(' ', '_', POST('c_name')) : POST('c_name');
     ossim_valid($c_name, OSS_SCORE, OSS_ALPHA, 'illegal:' . _('Category Name'));
     $data['status'] = 'error';
     $data['data'] = _('Error! Category not added');
     if (!ossim_error()) {
         if (!Category::exist($conn, $c_name)) {
             if (Category::insert($conn, $c_name)) {
                 $data['status'] = 'OK';
                 $data['data'] = _('Category added successfully');
             }
         } else {
             $data['data'] = _('Error! This category already exists');
         }
     } else {
         $data['data'] = ossim_get_error_clean();
     }
 } elseif ($action == 'delete_category') {
     $cat_id = GET('cat_id');
     ossim_valid($cat_id, OSS_DIGIT, 'illegal:' . _('Category'));
     $data['status'] = 'error';
     $data['data'] = _('Error! Category not deleted');
     if (!ossim_error()) {
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:31,代码来源:category.php


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