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


PHP Type::save方法代码示例

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


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

示例1: save

 public function save()
 {
     try {
         $model = new Type();
         $this->data->type->entry = 'typ_' . $this->data->type->entry;
         $model->setData($this->data->type);
         $model->save();
         $this->renderPrompt('information', 'OK', "editEntry('{$this->data->type->entry}');");
     } catch (\Exception $e) {
         $this->renderPrompt('error', $e->getMessage());
     }
 }
开发者ID:elymatos,项目名称:expressive_fnbr,代码行数:12,代码来源:TypeController.php

示例2: actionCreate

 /**
  *
  */
 public function actionCreate()
 {
     $model = new Type();
     if (($data = Yii::app()->getRequest()->getPost('Type')) !== null) {
         $model->setAttributes($data);
         if ($model->save() && $model->storeTypeAttributes(Yii::app()->getRequest()->getPost('attributes', []))) {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.store', 'Product type is created'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create']));
         }
     }
     $this->render('create', ['model' => $model, 'availableAttributes' => Attribute::model()->findAll()]);
 }
开发者ID:alextravin,项目名称:yupe,代码行数:15,代码来源:TypeBackendController.php

示例3: actionNew

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionNew()
 {
     $model = new Type();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Type'])) {
         $model->attributes = $_POST['Type'];
         if ($model->save()) {
             $this->redirect(array('view', 'type' => $model->TYPE_ID));
         }
     }
     $this->render('new', array('model' => $model));
 }
开发者ID:anjanababu,项目名称:Asset-Management,代码行数:17,代码来源:TypesController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::all();
     $type = new Type();
     $type->name = $data['name'];
     $type->short_name = $data['short_name'];
     try {
         $type->save();
     } catch (ValidationException $errors) {
         return Redirect::route('admin.types.create')->withErrors($errors->getErrors())->withInput();
     }
     return Redirect::route('admin.types.create')->withErrors(array('mainSuccess' => 'Видът на учебното заведение е успешно добавен.'));
 }
开发者ID:mertindervish,项目名称:registerbg,代码行数:18,代码来源:AdminTypeController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  * POST /clienttype
  *
  * @return Response
  */
 public function store()
 {
     Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $validation = Validator::make($input, Type::$rules);
     if ($validation->passes()) {
         $client = new Type();
         $client->client_type = strtoupper(Input::get('client'));
         $client->desc = strtoupper(Input::get('description'));
         $client->save();
         return Redirect::route('client.index')->with('class', 'success')->with('message', 'Record successfully created.');
     } else {
         return Redirect::route('client.create')->withInput()->withErrors($validation)->with('class', 'error')->with('message', 'There were validation error.');
     }
 }
开发者ID:jcyanga28,项目名称:project-reference,代码行数:21,代码来源:ClientTypeController.php

示例6: up

 public function up()
 {
     $db = Yii::app()->db;
     Yii::app()->setImport(['application.modules.store.models.*']);
     $cats = $db->createCommand("SELECT c1.* FROM site_store_category c1 LEFT JOIN site_store_category c2 ON c1.id=c2.parent_id WHERE c2.id IS NULL")->queryAll();
     foreach ($cats as $cat) {
         $Type = new Type();
         $Type->name = $cat['slug'];
         $Type->save();
         for ($i = 2; $i < 9; ++$i) {
             $TypeAttribute = new TypeAttribute();
             $TypeAttribute->type_id = $Type->id;
             $TypeAttribute->attribute_id = $i;
             $TypeAttribute->save();
         }
     }
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:17,代码来源:m151113_094352_store_fix.php

示例7: actionCreate

 /**
  * Создает новую модель Типа формы обучения.
  * Если создание прошло успешно - перенаправляет на просмотр.
  *
  * @return void
  */
 public function actionCreate()
 {
     $roles = ['1'];
     $role = \Yii::app()->user->role;
     if (array_intersect($role, $roles)) {
         $model = new Type();
         if (Yii::app()->getRequest()->getPost('Type') !== null) {
             $model->setAttributes(Yii::app()->getRequest()->getPost('Type'));
             if ($model->save()) {
                 Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ListnerModule.listner', 'Запись добавлена!'));
                 $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
             }
         }
         $this->render('create', ['model' => $model]);
     } else {
         throw new CHttpException(403, 'Ошибка прав доступа.');
     }
 }
开发者ID:shipovalovyuriy,项目名称:spasibeaucoup,代码行数:24,代码来源:TypeController.php

示例8: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Type();
     $condition = array('condition' => 'status=:status', 'params' => array(':status' => 1), 'order' => 'name');
     $levels = Level::model()->findAll($condition);
     $option_levels = array();
     foreach ($levels as $level) {
         $option_levels[$level->level_id] = $level->name;
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Type'])) {
         $model->attributes = $_POST['Type'];
         if ($model->save()) {
             $this->redirect(array('index', 'id' => $model->type_id));
         }
     }
     $this->render('create', array('model' => $model, 'option_levels' => $option_levels));
 }
开发者ID:ultr4h4ck,项目名称:project_gspa,代码行数:23,代码来源:TypeController.php

示例9: actionCreate

 public function actionCreate()
 {
     $model = new Type();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (($data = Yii::app()->getRequest()->getPost('Type')) !== null) {
         $model->setAttributes($data);
         $model->categories = serialize(Yii::app()->getRequest()->getPost('categories'));
         if ($model->save()) {
             $model->setTypeAttributes(Yii::app()->getRequest()->getPost('attributes'));
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.type', 'Тип товара создан.'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create']));
         }
     }
     //$criteria = new CDbCriteria();
     //$criteria->addNotInCondition('id', CHtml::listData($model->attributeRelation, 'attribute_id', 'attribute_id'));
     $availableAttributes = Attribute::model()->findAll();
     $this->render('create', ['model' => $model, 'availableAttributes' => $availableAttributes]);
 }
开发者ID:RonLab1987,项目名称:43berega,代码行数:19,代码来源:TypeBackendController.php

示例10: getSave

 public function getSave()
 {
     $id = Input::get('id');
     if ($id) {
         $Type = Type::find($id);
         $Type->name = Input::get('name');
         $Type->price = Input::get('price');
         $Type->description = Input::get('description');
         $Type->save();
         Session::flash('message', 'The records are updated successfully');
     } else {
         $Type = new Type();
         $Type->name = Input::get('name');
         $Type->price = Input::get('price');
         $Type->description = Input::get('description');
         $Type->save();
         Session::flash('message', 'The records are inserted successfully');
     }
     return Redirect::to('type');
 }
开发者ID:andrinda,项目名称:myhotel,代码行数:20,代码来源:TypeController.php

示例11: parametrize

 function parametrize($event = array())
 {
     $create = false;
     if (!empty($event['create']) && empty($event['errors'])) {
         $create = true;
         $entity = $event['create'];
     }
     if ($create) {
         switch ($entity) {
             case "types":
                 App::import('Model', 'Type');
                 $Type = new Type();
                 $types = array();
                 $types[] = array('type' => 'EMAIL', 'description' => 'Email access');
                 $types[] = array('type' => 'TWITTER', 'description' => 'Twitter access');
                 foreach ($types as $type) {
                     $Type->create();
                     $Type->save($type);
                 }
                 break;
         }
     }
 }
开发者ID:serumax,项目名称:pitutaria,代码行数:23,代码来源:params.php

示例12: run

 public function run($args)
 {
     $max_id = isset($args[0]) ? $args[0] : 0;
     $root = dirname(dirname(__DIR__));
     $parceBase = 'tiu_last';
     $log_spec = '/tmp/importTiuSpec.log';
     $log = '/tmp/importTiu.log';
     $k = file_get_contents($root . $log);
     $uploadDirectory = Yii::getPathOfAlias('webroot') . '/uploads/';
     $db = \Yii::app()->db;
     Yii::app()->setImport(['application.modules.store.models.*', 'application.models.*']);
     if ($max_id == 0) {
         $max_id = $db->createCommand()->select('MAX(id)')->from($parceBase . '.product')->queryScalar();
     }
     // импорт категорий
     if ($k == 0) {
         // перед созданием категорий все чистим
         echo "Clear tables and files... \n";
         $this->clear($uploadDirectory);
         echo "Set defaults... \n";
         $this->setDefault();
         $db->setActive(true);
         Yii::app()->language = 'ru';
         $categories = $db->createCommand("\n                SELECT name, id_item, id_parent FROM " . $parceBase . ".category_all\n            ")->queryAll();
         echo "Import categories... \n";
         foreach ($categories as $dump_category) {
             $category = new StoreCategory();
             $category->name_ru = $dump_category['name'];
             $category->tiu_id_item = $dump_category['id_item'];
             $category->status = 1;
             $name_translit = \yupe\helpers\YText::translit(str_replace(" ", "-", $dump_category['name']));
             $slug = $db->createCommand()->select('slug')->from('site_store_category')->where('slug =  "' . $name_translit . '"')->queryScalar();
             if ($slug === FALSE) {
                 $category->slug = $name_translit;
             } else {
                 //$category->slug = time() . '_' . $name_translit;
                 $category->slug = substr(md5($category->tiu_id_item), 0, 10) . '_' . $name_translit;
                 //echo $category->slug."\n";
             }
             $parent_id = $db->createCommand()->select('id')->from('site_store_category')->where('tiu_id_item =  "' . $dump_category['id_parent'] . '"')->queryScalar();
             $category->parent_id = $parent_id ? $parent_id : 1;
             if (!$category->save()) {
                 echo "\n";
                 echo "Error save StoreCategory for tiu_id_item = " . $category->tiu_id_item . "\n";
                 echo "\n";
             }
         }
         // создание типов
         echo "Create types... \n";
         $db->setActive(true);
         $cats = $db->createCommand("SELECT * FROM site_store_category")->queryAll();
         foreach ($cats as $cat) {
             $Type = new Type();
             $Type->name = $cat['slug'];
             if (!$Type->save()) {
                 echo "\n";
                 echo "Error save Type for {$cat['slug']} \n";
                 echo "\n";
                 continue;
             }
             // добавим постоянные характеристики
             foreach ($this->attr_id as $attr_id) {
                 $TypeAttribute = new TypeAttribute();
                 $TypeAttribute->type_id = $Type->id;
                 $TypeAttribute->attribute_id = $attr_id;
                 $TypeAttribute->save();
             }
         }
         $k = 1;
         file_put_contents($root . $log, $k);
     }
     // импорт продуктов
     echo "Import products... \n";
     echo "Max ID {$max_id} \n";
     for ($k; $k <= $max_id; $k++) {
         //			$db->setActive(false);
         $db->setActive(true);
         $dump_product = $db->createCommand()->select('*')->from($parceBase . '.product')->where('id =' . $k)->queryRow();
         if ($dump_product) {
             $name_translit = \yupe\helpers\YText::translit(str_replace(" ", "", $dump_product['name']));
             if (empty($name_translit)) {
                 file_put_contents($root . $log, $dump_product['id']);
                 continue;
                 // нет имени
             }
             $id_cat = $db->createCommand()->select('id_cat')->from($parceBase . '.productToCat')->where('id_product =' . $dump_product['id'])->queryScalar();
             if ($id_cat === FALSE) {
                 file_put_contents($root . $log, $dump_product['id']);
                 continue;
                 // нет категории
             }
             // скачаем файлы
             $image = $db->createCommand()->select('url')->from($parceBase . '.image')->where('id_item =' . $dump_product['id'])->queryRow();
             if ($image !== null && $image['url'] != '') {
                 $imageContent = $this->getData($image['url']);
                 if ($imageContent) {
                     $this->addToFiles('qqurl', $image['url']);
                     $file = new File();
                     $fileinfo = $file->uploadFile($uploadDirectory, array("jpg", "png", "jpeg"), 'Product');
                     // создание продукта
//.........这里部分代码省略.........
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:101,代码来源:ImportBaseTiuCommand.php

示例13: postType

 public function postType($type_id)
 {
     $all = Input::all();
     $rules = array('name' => 'required|min:2|max:255', 'type' => 'required|min:3|max:255');
     $validator = Validator::make($all, $rules);
     if ($validator->fails()) {
         return Redirect::to('/admin/content/' . $type_id)->withErrors($validator)->withInput()->with('error', 'Ошибка');
     }
     if (is_numeric($type_id)) {
         $post = Type::find($type_id);
     } else {
         $post = new Type();
     }
     $post->type = $all['type'];
     $post->name = $all['name'];
     $post->template = $all['template'];
     $post->title = $all['title'];
     $post->text = $all['text'];
     $post->status = isset($all['status']) ? true : false;
     $post->save();
     return Redirect::to('/admin/content/' . $type_id)->with('success', 'Изменения сохранены');
 }
开发者ID:ldin,项目名称:project_kartinki,代码行数:22,代码来源:AdminController.php

示例14: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aOffer !== null) {
             if ($this->aOffer->isModified() || $this->aOffer->isNew()) {
                 $affectedRows += $this->aOffer->save($con);
             }
             $this->setOffer($this->aOffer);
         }
         if ($this->aType !== null) {
             if ($this->aType->isModified() || $this->aType->isNew()) {
                 $affectedRows += $this->aType->save($con);
             }
             $this->setType($this->aType);
         }
         if ($this->aTypology !== null) {
             if ($this->aTypology->isModified() || $this->aTypology->isNew()) {
                 $affectedRows += $this->aTypology->save($con);
             }
             $this->setTypology($this->aTypology);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = CustomerPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = CustomerPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += CustomerPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:rewrewby,项目名称:propertyx,代码行数:63,代码来源:BaseCustomer.php

示例15: postTypeAdd

 public function postTypeAdd()
 {
     $validator = Validator::make(Input::all(), Type::$rules);
     if ($validator->fails()) {
         return Redirect::to('branch/type-add')->withErrors($validator)->withInput();
     }
     $type = new Type();
     $type->name = Input::get('name');
     $type->code = Input::get('code');
     $type->day = Input::get('day');
     $type->save();
     return Redirect::to('branch/type')->with('success', '客户类型添加成功!');
 }
开发者ID:huanghua581,项目名称:erp,代码行数:13,代码来源:BranchController.php


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