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


PHP Brand::save方法代码示例

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


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

示例1: testForTest

 public function testForTest()
 {
     TranslateAbility::setLanguageId(1);
     $brand = new \Brand(array('title' => 'Apple'));
     $this->assertEquals('Apple', $brand->title, 'Accessor after creating');
     $brand->save();
     $this->assertEquals('Apple', $brand->title, 'Accessor after saving');
     $brand = \Brand::loadOne(1);
     $this->assertEquals('Apple', $brand->title, 'Accessor after loading');
     $this->assertEquals(array('id_language' => 1, 'id_object' => 1, 'title' => 'Apple'), QC::create('brands_translate')->executeOne(), 'Data stored in DB after saving');
     TranslateAbility::setLanguageId(2);
     $brand->title = 'Яблоко';
     $brand->save();
     $this->assertEquals('Яблоко', $brand->title, 'Accessor after loading');
     $this->assertEquals(array('id_language' => 2, 'id_object' => 1, 'title' => 'Яблоко'), QC::create('brands_translate')->where('id_language = :d', 2)->executeOne(), 'Data stored in DB after saving');
     $brand->loadTranslation(1);
     $this->assertEquals('Apple', $brand->title, 'loadTranslation works');
     $this->assertEquals(array('id' => 1, 'id_object' => 1, 'id_language' => 2, 'title' => 'Яблоко'), $brand->getTranslationForLanguage(2), 'getTranslationForLanguage');
     TranslateAbility::setLanguageId(1);
     $brand2 = new \Brand();
     $brand2->title = 'Samsung';
     $brand2->save();
     $brand2->loadTranslation(2);
     $this->assertEmpty($brand2->title, 'Empty data for not translated item');
     $brands = \Brand::loadList();
     $this->assertEquals(array('Apple', 'Samsung'), $brands->getFieldArray('title'), 'Loaded two translated items');
     $brands->loadTranslation(2);
     $this->assertEquals(array('Яблоко', null), $brands->getFieldArray('title'), 'Loaded two not fully translated items');
     $this->assertEquals(array(1 => array('id' => 1, 'id_object' => 1, 'id_language' => 1, 'title' => 'Apple'), 2 => array('id' => 1, 'id_object' => 1, 'id_language' => 2, 'title' => 'Яблоко')), $brand->getAllTranslations(), 'getAllTranslations()');
 }
开发者ID:solve,项目名称:database,代码行数:30,代码来源:ModelAbilityTranslateTest.php

示例2: run

 public function run()
 {
     DB::table('brands')->truncate();
     $brand = new Brand();
     $brand->name = "5TheWay";
     $brand->save();
     $brand = new Brand();
     $brand->name = "Nike";
     $brand->save();
     $brand = new Brand();
     $brand->name = "Adidas";
     $brand->save();
     $brand = new Brand();
     $brand->name = "Puma";
     $brand->save();
     $brand = new Brand();
     $brand->name = "Ripcurl";
     $brand->save();
     $brand = new Brand();
     $brand->name = "The Northface";
     $brand->save();
     $brand = new Brand();
     $brand->name = "Overdose";
     $brand->save();
     $brand = new Brand();
     $brand->name = "Kenstyle";
     $brand->save();
     $brand = new Brand();
     $brand->name = "Real Tree";
     $brand->save();
     $brand = new Brand();
     $brand->name = "Game Guard";
     $brand->save();
 }
开发者ID:hungleon2112,项目名称:giaymaster,代码行数:34,代码来源:BrandTableSeeder.php

示例3: testImages

 public function testImages()
 {
     $brand = new \Brand(array('title' => 'test'));
     $brand->save();
     $brand->attachFileFromPath('avatar', __DIR__ . '/assets/flower.jpg');
     $this->assertEquals('04/4/avatar/small/' . $brand->avatar['full_name'], $brand->avatar['small']['link'], 'Small avatar works');
 }
开发者ID:solve,项目名称:database,代码行数:7,代码来源:ModelAbilityFilesTest.php

示例4: actionAjax

 public function actionAjax()
 {
     if (Yii::app()->request->isAjaxRequest) {
         if (isset($_POST['Brand']['id']) && !empty($_POST['Brand']['id'])) {
             $model = $this->loadModel($_POST['Brand']['id']);
             $model->attributes = $_POST['Brand'];
             if ($model->validate()) {
                 if (Yii::app()->params['server'] == CAlexHelper::DEVELOPMENT || $_POST['Brand']['id'] > 60) {
                     if ($model->save()) {
                         $this->setNotice('Запись успешно обновлена');
                         $model = new Brand();
                     } else {
                         $this->setNotice('Fail');
                     }
                 } else {
                     $this->setNotice('You cant edit data on this site');
                 }
             }
         } else {
             $model = new Brand();
             $model->attributes = $_POST['Brand'];
             if ($model->validate()) {
                 if ($model->save()) {
                     $this->setNotice('Запись успешно добавлена');
                     $model = new Brand();
                 } else {
                     $this->setNotice('Fail');
                 }
             }
         }
         $this->renderPartial('ajaxForm', array('model' => $model));
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
开发者ID:rahmanjis,项目名称:yii-catalog,代码行数:35,代码来源:BrandController.php

示例5: postSave

 public function postSave()
 {
     $brand = new Brand();
     $brand->client_id = Input::get('client_id');
     $brand->brand_name = Input::get('brand_name');
     $brand->category_id = Input::get('category_id');
     $brand->save();
     return Response::json($brand);
 }
开发者ID:saifurrahman,项目名称:dev,代码行数:9,代码来源:BrandController.php

示例6: executeAddBrand

 public function executeAddBrand(sfWebRequest $request)
 {
     try {
         $q = new Brand();
         $q->setBrandName($request->getParameter('brand_name'));
         $q->save();
         $this->res = "Brand Added!";
     } catch (Exception $exc) {
         $this->res = $exc->getMessage();
     }
 }
开发者ID:navid045,项目名称:maxlaptop,代码行数:11,代码来源:actions.class.php

示例7: Brand

 function test_delete()
 {
     $name = "Nike";
     $test_brand = new Brand($name, $id);
     $test_brand->save();
     $name2 = "Adidas";
     $test_brand2 = new Brand($name2, $id);
     $test_brand2->save();
     $test_brand->delete();
     $this->assertEquals([$test_brand2], Brand::getAll());
 }
开发者ID:jeffaustin81,项目名称:shoe_store,代码行数:11,代码来源:BrandTest.php

示例8: testDelete

 function testDelete()
 {
     $name = "Zelds";
     $test_store = new Store($name);
     $test_store->save();
     $name = "Granite";
     $test_brand = new Brand($name);
     $test_brand->save();
     $test_brand->addStore($test_brand);
     $test_brand->delete();
     $this->assertEquals([], $test_brand->getStores());
 }
开发者ID:alexMcosta,项目名称:Shoes_Brands,代码行数:12,代码来源:BrandTest.php

示例9: testBasic

 public function testBasic()
 {
     $brand = new \Brand(array('title' => 'Apple'));
     $brand->save();
     $this->assertEquals('apple', $brand->getSlug(), 'slug ability for Apple');
     $brand->setTitle('Саша')->save();
     $this->assertEquals('sasha', $brand->getSlug(), 'slug ability for Sasha');
     $brand->setTitle('')->save();
     $this->assertEquals('n-a', $brand->getSlug(), 'slug ability for empty');
     $brand->setTitle('12 -_  s')->save();
     $this->assertEquals('12-s', $brand->getSlug(), 'slug ability for bad string');
 }
开发者ID:solve,项目名称:database,代码行数:12,代码来源:ModelAbilitySlugTest.php

示例10: testAddBrand

 function testAddBrand()
 {
     $store_name = "Beacons Closet";
     $new_store = new Store($store_name);
     $new_store->save();
     $brand_name = "dr.martens";
     $new_brand = new Brand($brand_name);
     $new_brand->save();
     $new_store->addBrand($new_brand);
     $result = $new_store->getBrands();
     $this->assertEquals($new_brand, $result[0]);
 }
开发者ID:jschold,项目名称:shoe_stores,代码行数:12,代码来源:StoreTest.php

示例11: actionCreate

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

示例12: add

 public static function add()
 {
     return function ($req, $res) {
         $res->header('Content-Type', 'application/json; charset=utf-8');
         $raw = file_get_contents("php://input");
         $data = json_decode($raw);
         $model = new Brand();
         $model->name = $data->name;
         $model->description = $data->description;
         $model->save();
         echo $model;
     };
 }
开发者ID:samdubey,项目名称:ads2,代码行数:13,代码来源:brandctrl.php

示例13: postCreate

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), Brand::$rules);
     if ($validator->passes()) {
         $brand = new Brand();
         $brand->brand = Input::get('brand');
         $brand->subcategory_id = Input::get('subcategory_id');
         $brand->save();
         return Redirect::back()->with('success', 'Brand added successfully.');
     } else {
         return Redirect::back()->withErrors($validator);
     }
 }
开发者ID:bytebybyte,项目名称:laravel-ecommerce,代码行数:18,代码来源:BrandsController.php

示例14: actionCreate

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

示例15: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     //
     $validation = Validate::BrandValidation(Input::all());
     if ($validation->fails()) {
         return Redirect::to('marca/create')->withErrors($validation)->withInput();
     } else {
         $brand = new Brand();
         $brand->brand = Input::get('brand');
         $brand->save();
         return Redirect::to('admin/marca');
     }
 }
开发者ID:abrahammontas,项目名称:Supplements-online-store,代码行数:19,代码来源:BrandController.php


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