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


PHP Option::save方法代码示例

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


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

示例1: add

 public function add($data)
 {
     global $wpdb;
     $entity = new Entity();
     $option = new Option();
     $dataEntity = ['activate' => $data['activate'], 'sm_entity_id' => $data['sm_entity_id'], 'author_id' => wp_get_current_user()->ID, 'name' => $data['name'], 'last_published_message' => date('Y-m-d H:i:s')];
     $entityID = $entity->save($dataEntity);
     foreach ($data['category'] as $key => $value) {
         $dataOption = ['option_id' => 1, 'value' => $value];
         $option->save($dataOption, $entityID);
     }
     $dataOption = ['option_id' => 2, 'value' => $data['display_type']];
     $option->save($dataOption, $entityID);
     $dataOption = ['option_id' => 3, 'value' => $data['publish_type']];
     $option->save($dataOption, $entityID);
     $dataOption = ['option_id' => 4, 'value' => $data['link_canonical']];
     $option->save($dataOption, $entityID);
     $dataOption = ['option_id' => 5, 'value' => $data['image']];
     $option->save($dataOption, $entityID);
     $dataOption = ['option_id' => 6, 'value' => $data['readmore']];
     $option->save($dataOption, $entityID);
     $dataOption = ['option_id' => 7, 'value' => $data['noIndex']];
     $option->save($dataOption, $entityID);
     $dataOption = ['option_id' => 8, 'value' => $data['noFollow']];
     $option->save($dataOption, $entityID);
     $dataOption = ['option_id' => 9, 'value' => $data['morebalise']];
     $option->save($dataOption, $entityID);
 }
开发者ID:alhenaconseil,项目名称:wordpress-sociallymap,代码行数:28,代码来源:EntityCollection.php

示例2: set2Db

 /**
  * 更新Option的值
  */
 private function set2Db($key, $value)
 {
     $item = Option::model()->find("option_name=:option_name", array("option_name" => $key));
     if (!isset($item)) {
         $item = new Option();
         $item->option_name = $key;
     }
     $item->option_value = $value;
     $item->save();
     return $item;
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:14,代码来源:MiniOption.php

示例3: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // import options
     $options = config('options');
     $options['version'] = config('app.version');
     $options['announcement'] = str_replace('{version}', $options['version'], $options['announcement']);
     foreach ($options as $key => $value) {
         Option::set($key, $value);
     }
     Option::save();
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:16,代码来源:2016_11_18_134542_import_options.php

示例4: actionCreate

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

示例5: actionCreate

 public function actionCreate()
 {
     $model = new Option();
     $description = new OptionDescription();
     $optionValue = new OptionValue();
     $optionValueDes = new OptionValueDescription();
     //$optionValueData = new CArrayDataProvider($this->_optionvalue);
     $this->performAjaxValidation(array($model, $description, $optionValue), 'option-form');
     if (isset($_POST[$this->modelName])) {
         $model->setAttributes($_POST[$this->modelName]);
         $description->setAttributes($_POST[$this->modelName . 'Description']);
         //$optionValue->setAttributes($_POST['OptionValue']);
         $suc = Yii::t('info', 'Option was successfully created');
         $err = Yii::t('info', 'Could not update Option');
         $errOpt = Yii::t('info', 'Please fill in the name and sort number for each option value');
         $description->option_id = 0;
         $description->locale_code = Yii::app()->getLanguage();
         if ($model->validate() && $description->validate() && $this->validateOptionValue()) {
             if ($model->save()) {
                 $description->option_id = $model->id;
                 $description->save();
                 foreach ($this->_optionvalue as $i => $optionvalue) {
                     $optionvalue->option_id = $model->id;
                     $optionvalue->save();
                     $this->_optionvaluedes[$i]->option_value_id = $optionvalue->id;
                     $this->_optionvaluedes[$i]->option_id = $model->id;
                     $this->_optionvaluedes[$i]->save();
                 }
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, $suc);
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial('_view', array('model' => $model, 'description' => $description, 'optionValue' => $this->_optionvalue, 'optionValueDes' => $this->_optionvaluedes, 'optionValueData' => new CArrayDataProvider($this->_optionvalue)), false, true);
                     Yii::app()->end();
                 } else {
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             } else {
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $err);
             }
         } else {
             $description->validate();
             if (!$this->validateOptionValue()) {
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $errOpt);
             }
         }
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->renderPartial('_form', array('model' => $model, 'description' => $description, 'optionValue' => $this->_optionvalue, 'optionValueDes' => $this->_optionvaluedes, 'optionValueData' => new CArrayDataProvider($this->_optionvalue)), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'description' => $description, 'optionValue' => $this->_optionvalue, 'optionValueDes' => $this->_optionvaluedes, 'optionValueData' => new CArrayDataProvider($this->_optionvalue)));
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:51,代码来源:OptionController.php

示例6: up

 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     //
     Schema::create('options', function ($table) {
         $table->increments('id');
         $table->boolean('activate_pn');
         $table->string('basic_name');
         $table->string('basic_pass');
         $table->timestamps();
     });
     $o = new Option();
     $o->activate_pn = 0;
     $o->save();
 }
开发者ID:dldude,项目名称:recurly-push-notification-example,代码行数:19,代码来源:2012_10_31_155222_options_table.php

示例7: refresh

 public static function refresh()
 {
     $defaults = Config::get('options.defaults');
     foreach ($defaults as $d => $v) {
         $opt = Option::where('varname', $d)->first();
         if ($opt) {
         } else {
             $opt = new Option();
             $opt->varname = $d;
             foreach ($v as $k => $v) {
                 $opt->{$k} = $v;
             }
             $opt->save();
         }
     }
 }
开发者ID:awidarto,项目名称:tmadminflat,代码行数:16,代码来源:Options.php

示例8: postQuestionChange

 public function postQuestionChange()
 {
     //message-notification
     $messages = array();
     //handle navigation
     $admin_navigation = new AdminNavigation();
     if ($admin_navigation->isNavigate()) {
         return $admin_navigation->goToN();
     }
     //handle chapter-text change
     //redirect after changed
     if (Input::has('chapter_change')) {
         $chapter = Chapter::find(Input::get('chapter_change'));
         $chapter->text = Input::get('chapter_text');
         $chapter->save();
         $messages['chapter_change_text'] = 'chapter-' . $chapter->id . ':saved';
         $this->messageController->send($messages, $this::MESSAGE_KEY);
         return Redirect::back();
     }
     //handle delete-question
     //redirect after deleted, no need to modify other inputs
     if (Input::has('delete_question')) {
         $question = Question::find(Input::get('delete_question'));
         $store_question_id = $question->id;
         $question->delete();
         $messages['delete_question'] = 'question-' . $store_question_id . ':deleted';
         $this->messageController->send($messages, $this::MESSAGE_KEY);
         return Redirect::back();
     }
     //handle change on a question (both this one, and it's options)
     //redirect after all-changes saved
     if (Input::has('question_change')) {
         $question = Question::find(Input::get('question_change'));
         //question-change, change question-text
         if (Input::has('question_text')) {
             $question->text = Input::get('question_text');
             $question->save();
             $messages['question_change_text'] = 'question-' . $question->id . ':saved';
         }
         //question-change, change question-chapter_id
         if (Input::has('chapter_id')) {
             $question->chapter_id = Input::get('chapter_id');
             $question->save();
             $new_chapter = $question->getChapter;
             $messages['question_change_chapter_id'] = 'question-' . $question->id . ':now belongs to chapter-' . $new_chapter->id;
         }
         //options-change
         if (Input::has('options')) {
             $options = Input::get('options');
             //save options-change
             $i = -1;
             foreach ($options as $option_id => $option_text) {
                 $option = Option::find($option_id);
                 $option->text = $option_text;
                 //reset all option-is_right = 0
                 //is_right set again with input-is_right checked
                 $option->is_right = 0;
                 $option->save();
                 $messages['options_change[' . ++$i . ']'] = 'option-' . $option->id . ':saved';
             }
             //modify option-is_right
             if (Input::has('is_right')) {
                 $option = Option::find(Input::get('is_right'));
                 //this option set is_right = 1
                 $option->is_right = 1;
                 $option->save();
                 $messages['options_change_is_right'] = 'option-' . $option->id . '-is_right:saved';
             }
         }
         //send message-notification
         $this->messageController->send($messages, $this::MESSAGE_KEY);
         return Redirect::back();
     }
     //new-question
     //redirect after create new-one
     if (Input::has('new_question')) {
         //save new question
         $question = new Question();
         //delete + auto_increment >>> modify question-id not continuous
         //manually change question-id
         $last_question = Question::all()->last();
         $question->id = $last_question->id + 1;
         $question->text = Input::get('question_text');
         $question->chapter_id = Input::get('chapter_id');
         $question->save();
         $question_id = $question->id;
         $messages['new_question'] = 'question-' . $question->id . ':saved';
         //save new options
         $options_text = Input::get('options');
         $created_options = array();
         for ($i = 0; $i < 4; $i++) {
             $option = new Option();
             $option->text = $options_text[$i];
             $option->question_id = $question_id;
             $option->is_right = 0;
             $option->save();
             //store in array new-option in $created_options, to add is_right on which
             $created_options[$i] = $option;
             $messages['option[' . $i . ']'] = 'option-' . $option->id . ':saved';
         }
//.........这里部分代码省略.........
开发者ID:hoanganh25991,项目名称:multiple-choice-test,代码行数:101,代码来源:ChaptersController.php

示例9: postConfigSave

 public function postConfigSave()
 {
     if (Payment::VeryPayment() == false) {
         return View::make('clinic.payment.renews-payment');
     }
     $data = array("name" => Input::get("name"), "insurance" => Input::get("insurance"), "lang" => Input::get("lang"), "picture" => Input::file("picture"), "phone" => Input::get("phone"));
     $rules = array("name" => 'required|min:1|max:255', "insurance" => 'required|min:1|max:255', "lang" => 'required|min:1|max:10', "picture" => 'mimes:jpeg,gif,png', "phone" => 'required|numeric|min:1');
     $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen :attribute debe ser jpg, git, png');
     $validation = Validator::make(Input::all(), $rules, $messages);
     //si la validación falla redirigimos al formulario de registro con los errores
     //y con los campos que nos habia llenado el usuario
     if ($validation->fails()) {
         return Redirect::to('/clinic/config-data/')->withErrors($validation)->withInput();
     } else {
         $id = Input::get("id");
         $clinic = Clinic::find($id);
         $clinic->name = Input::get("name");
         $clinic->phone = Input::get("phone");
         $clinic->insurances = Input::get("insurance");
         if (Input::file('picture') != NULL) {
             //agrega imagen de logo
             $file_logo = Input::file('picture');
             $ext = Input::file('picture')->getClientOriginalExtension();
             $nameIMG = date('YmdHis');
             $logo = $nameIMG . '.' . $ext;
             $logo = 'assets/clinic/images/logo/logo_' . $logo;
             $file_logo->move("assets/clinic/images/logo/", $logo);
             $clinic->picture = $logo;
         }
         $clinic->save();
         $adress = Address::find($clinic->address_id);
         $adress->my_address = Input::get("address");
         $adress->save();
         $lang = Option::where('name', $clinic->id . '-clinic-lang')->first();
         if ($lang) {
             $lang->key = Input::get("lang");
             $lang->save();
         } else {
             $langadd = new Option();
             $langadd->key = Input::get("lang");
             $langadd->name = $clinic->id . '-clinic-lang';
             $langadd->save();
         }
         return Redirect::back();
     }
 }
开发者ID:jnicolasbc,项目名称:admin_swp_com,代码行数:46,代码来源:ClinicController.php

示例10: array

    $suitable_option_ids = Option::getIdsFromNames($suitable_option_names);
    $options = Option::getObjects($suitable_option_ids);
    $suitable_restaurants = Restaurant::suitableRestaurants($suitable_option_ids);
    return $app['twig']->render('results.html.twig', array('suitable_restaurants' => $suitable_restaurants, 'options' => $options));
});
$app->get('/admin', function () use($app) {
    return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/add_restaurants', function () use($app) {
    $restaurant_name = new Restaurant($_POST['restaurant_name']);
    $restaurant_name->save();
    return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/add_options', function () use($app) {
    $option_name = new Option($_POST['option_name']);
    $option_name->save();
    return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/add_restaurant_options', function () use($app) {
    $restaurant = Restaurant::find($_POST['restaurant_id']);
    $option = Option::find($_POST['option_id']);
    $restaurant->addOption($option);
    return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'restaurant_options' => $restaurant->getOptions(), 'all_options' => Option::getAll()));
});
$app->post('/add_option_restaurants', function () use($app) {
    $option = Option::find($_POST['option_id']);
    $restaurant = Restaurant::find($_POST['restaurant_id']);
    $option->addRestaurant($restaurant);
    return $app['twig']->render('option.html.twig', array('option' => $option, 'option_restaurants' => $option->getRestaurants(), 'all_restaurants' => Restaurant::getAll()));
});
$app->get('/restaurants/{id}', function ($id) use($app) {
开发者ID:ben-pritchard,项目名称:allergen_avoider,代码行数:31,代码来源:app.php

示例11: save_tag

 public function save_tag()
 {
     $id = Input::get('id');
     $tag = Option::find($id);
     if (!$tag) {
         $tag = new Option();
     }
     $tag->name = Input::get('name');
     $tag->save();
     $message = "Successfully updated the product tag";
     $type = "success";
     return Redirect::to('/admin/tags')->with('type', $type)->with('message', $message);
 }
开发者ID:sohelrana820,项目名称:mario-gomez,代码行数:13,代码来源:AdminController.php

示例12: getConfigSave

 public function getConfigSave()
 {
     if (Payment::VeryPayment() == false) {
         return View::make('clinic.payment.renews-payment');
     }
     $data = array("insurance" => Input::get("insurance"), "lang" => Input::get("lang"));
     $rules = array("insurance" => 'required|min:1|max:100', "lang" => 'required|min:1|max:100');
     $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen logo debe ser jpg, git, png');
     $validation = Validator::make(Input::all(), $rules, $messages);
     //si la validación falla redirigimos al formulario de registro con los errores
     //y con los campos que nos habia llenado el usuario
     if ($validation->fails()) {
         return Redirect::to('/clinic/config-data/')->withErrors($validation)->withInput();
     } else {
         $id = Doctor::doctorLogin();
         $doctor = Doctor::where('id', $id)->first();
         $lang = Option::where('name', $id . '-doctor-lang')->first();
         if ($lang) {
             $lang->key = Input::get("lang");
             $lang->save();
         } else {
             $langadd = new Option();
             $langadd->key = Input::get("lang");
             $langadd->name = $id . '-doctor-lang';
             $langadd->save();
         }
         $opcionSeg = Option::where('name', $id . '-doctor-insurance')->first();
         if ($opcionSeg) {
             $segs = explode(',', Input::get("insurance"));
             $segok = '';
             foreach ($segs as $seg) {
                 $very = Insurance::where('name', 'like', '%' . $seg . '%')->first();
                 if ($very) {
                     $segok = $segok . ',' . $seg;
                 }
             }
             $opcionSeg->key = $segok;
             $opcionSeg->save();
         } else {
             $segs = explode(',', Input::get("insurance"));
             $seguok = '';
             foreach ($segs as $seg) {
                 $very = Insurance::where('name', $seg)->first();
                 if ($very) {
                     $seguok = $seguok . ',' . $seg;
                 }
             }
             $addseg = new Option();
             $addseg->name = $id . '-doctor-insurance';
             $addseg->key = $seguok;
             $addseg->save();
         }
         return Redirect::back();
     }
 }
开发者ID:jnicolasbc,项目名称:admin_swp_com,代码行数:55,代码来源:DoctorController.php

示例13: saveTask

 /**
  * Save an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     $fields = array('id' => Request::getInt('id', 0, 'post'), 'title' => Request::getVar('title', '', 'post'), 'alias' => Request::getVar('alias', '', 'post'), 'lag' => Request::getVar('lag', '', 'post'), 'published' => Request::getVar('published', '', 'post'), 'open' => Request::getVar('open', '', 'post'));
     // Save the poll parent information
     $row = Poll::oneOrNew($fields['id'])->set($fields);
     if (!$row->save()) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     $row->checkin();
     // Save the poll options
     $options = Request::getVar('polloption', array(), 'post');
     foreach ($options as $i => $text) {
         $option = new Option();
         $option->pollid = (int) $row->id;
         $option->text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
         if ($fields['id']) {
             $option->id = (int) $i;
         }
         if (!$option->save()) {
             Notify::error($option->getError());
         }
     }
     Notify::success(Lang::txt('COM_POLL_ITEM_SAVED'));
     if ($this->_task == 'apply') {
         return $this->editTask($row);
     }
     App::redirect(Route::url('index.php?option=com_poll', false));
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:36,代码来源:polls.php

示例14: Restaurant

 function test_suitableRestaurants()
 {
     // arrange
     $restaurant_name = "Taco Hell";
     $test_restaurant = new Restaurant($restaurant_name);
     $test_restaurant->save();
     $restaurant_name2 = "Burger Queen";
     $test_restaurant2 = new Restaurant($restaurant_name2);
     $test_restaurant2->save();
     $option_name = "Shellfish-free";
     $test_option = new Option($option_name);
     $test_option->save();
     $option_name2 = "Gasoline-free";
     $test_option2 = new Option($option_name2);
     $test_option2->save();
     $option_name3 = "Soy-free";
     $test_option3 = new Option($option_name3);
     $test_option3->save();
     // act
     $test_restaurant->addOption($test_option2);
     $test_restaurant->addOption($test_option3);
     $test_restaurant2->addOption($test_option);
     $test_restaurant2->addOption($test_option2);
     $test_restaurant2->addOption($test_option3);
     $option_ids = array();
     array_push($option_ids, $test_option->getId());
     array_push($option_ids, $test_option3->getId());
     $result = Restaurant::suitableRestaurants($option_ids);
     // assert
     $this->assertEquals([$test_restaurant2], $result);
 }
开发者ID:ben-pritchard,项目名称:allergen_avoider,代码行数:31,代码来源:RestaurantTest.php

示例15: Option

 function test_getIdsFromNames()
 {
     //arrange
     $name = "peanut-free";
     $test_option = new Option($name);
     $test_option->save();
     $name2 = "soy-free";
     $test_option2 = new Option($name2);
     $test_option2->save();
     //act
     $suitable_options_names = array($test_option->getName(), $test_option2->getName());
     $result = Option::getIdsFromNames($suitable_options_names);
     //assert
     $this->assertEquals([$test_option->getId(), $test_option2->getId()], $result);
 }
开发者ID:ben-pritchard,项目名称:allergen_avoider,代码行数:15,代码来源:OptionTest.php


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