本文整理汇总了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()');
}
示例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();
}
示例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');
}
示例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.');
}
}
示例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);
}
示例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();
}
}
示例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());
}
示例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());
}
示例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');
}
示例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]);
}
示例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));
}
示例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;
};
}
示例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);
}
}
示例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));
}
示例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');
}
}