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


PHP Car::save方法代码示例

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


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

示例1: createAndSaveRawModelWithManyToManyRelation

 public static function createAndSaveRawModelWithManyToManyRelation()
 {
     include_once __DIR__ . '/../scripts/tested_models.php';
     $car = new \Car();
     $car->nameCar = 'AcmeCar';
     $car->noteCar = '10';
     $car->idBrand = 1;
     $car->save();
     $tags = array();
     $tag1 = new \Tag();
     $tag1->libTag = 'Sport';
     $tag1->save();
     $tag2 = new \Tag();
     $tag2->libTag = 'Family';
     $tag2->save();
     $tag3 = new \Tag();
     $tag3->libTag = 'Crossover';
     $tag3->save();
     $tags[] = $tag1;
     $tags[] = $tag2;
     $tags[] = $tag3;
     $car->setTag($tags);
     $car->save();
     // create test
     $req = \PicORM\Model::getDataSource()->prepare('SELECT count(*) as nb FROM car_have_tag WHERE idCar = ?');
     $req->execute(array($car->idCar));
     $resultBDD = $req->fetch(\PDO::FETCH_ASSOC);
     return array(array($car, $tags, $resultBDD));
 }
开发者ID:peacq,项目名称:picorm,代码行数:29,代码来源:Model.php

示例2: postCreate

 public function postCreate()
 {
     $validator = Validator::make(Input::all(), Car::$rules);
     if ($validator->passes()) {
         $car = new Car();
         $car->type_id = Input::get('type_id');
         $car->title = Input::get('title');
         if (Input::get('description')) {
             $car->description = Input::get('description');
         }
         $car->price = Input::get('price');
         $car->available_at = Input::get('available_at');
         $car->transmission = Input::get('transmission');
         $car->aircon = Input::get('aircon');
         $car->seats = Input::get('seats');
         $car->doors = Input::get('doors');
         $image = Input::file('image');
         $filename = date('Y-m-d-H:i:s') . "-" . $image->getClientOriginalName();
         Image::make($image->getRealPath())->resize(220, 128)->save('public/img/cars/' . $filename);
         $car->image = 'img/cars/' . $filename;
         $car->save();
         return Redirect::to('admin/cars/index')->with('message', 'New Car Added');
     }
     return Redirect::to('admin/cars/index')->with('message', 'Something went wrong')->withErrors($validator)->withInput();
 }
开发者ID:madiarsa,项目名称:laravel-4.1-car-rental-site,代码行数:25,代码来源:CarsController.php

示例3: store

 /**
  * Store a newly created car in storage.
  *
  * @return Response
  */
 public function store()
 {
     $messages = array('make.required' => 'Make field cannot be left empty.', 'make.max' => 'You must enter a value with a maximum of 255 characters.', 'model.required' => 'Model field cannot be left empty.', 'model.max' => 'You must enter a value with a maximum of 255 characters.', 'license_plate_number.required' => 'License Plate Number field cannot be left empty.', 'license_plate_number.max' => 'You must enter a value with a maximum of 255 characters.', 'color.required' => 'Color field cannot be left empty.', 'color.max' => 'You must enter a value with a maximum of 255 characters.');
     $validator = Validator::make($data = Input::all(), Car::$rules, $messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $car = new Car();
         $car->make = Input::get('make');
         $car->model = Input::get('model');
         $car->license_plate_number = Input::get('license_plate_number');
         $car->color = Input::get('color');
         if (Auth::check()) {
             $car->user_id = Auth::user()->id;
         }
         $result = $car->save();
     }
     if ($result && Auth::check()) {
         Session::flash('successMessage', 'Thank you for saving your car');
         return Redirect::action('cars.index');
     } else {
         if ($result && !Auth::check()) {
             $carId = $car->id;
             return Response::json($carId);
         } else {
             Session::flash('errorMessage', 'Please properly input all the required fields');
             Log::warning('Car failed to save: ', Input::all());
             return Redirect::back()->withInput();
         }
     }
 }
开发者ID:Park-It,项目名称:parkit.dev,代码行数:36,代码来源:CarsController.php

示例4: actionCreate

 public function actionCreate()
 {
     $model = new Car();
     $file = new File();
     $model->create_at = date('Y-m-d');
     if (isset($_POST['Car']) && isset($_POST['File'])) {
         $model->attributes = $_POST['Car'];
         $file->attributes = $_POST['File'];
         $model->validate();
         if ($model->getErrors() == null) {
             $model->date_registration = Tools::dateToSave($model->date_registration);
             $file->file = CUploadedFile::getInstance($file, 'file');
             if ($file->file != null) {
                 $filename = time() . '.' . $file->file->getExtensionName();
                 $file->file->saveAs(Yii::app()->params['pathUpload'] . $filename);
                 $model->pic = $filename;
             } else {
                 $model->pic = 'noimage.jpg';
             }
             $model->save();
             $this->redirect(array('view', 'id' => $model->car_id));
         }
     }
     $this->render('create', array('model' => $model, 'file' => $file));
 }
开发者ID:vasitjuntong,项目名称:carsnru,代码行数:25,代码来源:CarController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $inputs = Input::all();
     $catalog = new Catalog();
     $catalog->title = $inputs['title'];
     $catalog->description = $inputs['description'];
     $catalog->user_id = Auth::user()->id;
     $catalog->save();
     $car = new Car();
     $car->brand = $inputs['brand'];
     $car->engine = $inputs['engine'];
     $car->make = $inputs['make'];
     $car->milage = $inputs['milage'];
     $car->type = $inputs['type'];
     $car->transmission = $inputs['transmission'];
     $car->status = $inputs['status'];
     $car->location = $inputs['location'];
     $car->price = $inputs['price'];
     $car->youtube = $inputs['youtube'];
     $car->main_pic = 0;
     $car->user_id = Auth::user()->id;
     $car->catalog_id = $catalog->id;
     $car->save();
     $pictures = $inputs['pictures'];
     Log::info(user_photo_path() . $catalog->id . '/');
     if (!File::isDirectory(user_photo_path() . $catalog->id . '/')) {
         File::makeDirectory(user_photo_path() . $catalog->id . '/', 0777, true, true);
     }
     if (Input::hasFile('pictures[]')) {
         foreach ($pictures as $picture) {
             if ($picture != null) {
                 $image = Image::make($picture->getRealPath());
                 $fileName = str_replace(' ', '_', strrolower($picture->getClientOriginalName()));
                 $image->resize(1024, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . $fileName)->resize(750, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '750-' . $fileName)->resize(500, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '500-' . $fileName)->resize(250, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '250-' . $fileName);
                 $pic = new Pictures();
                 $pic->url = $fileName;
                 $pic->user_id = Auth::user()->id;
                 $pic->catalog_id = $catalog->id;
                 $pic->type = 'catalog';
                 $pic->save();
             }
         }
     }
     return Redirect::route('admin.catalog.index')->with('success', Lang::get('messages.catalog_created'));
 }
开发者ID:stefferd,项目名称:autogarageooij,代码行数:58,代码来源:CatalogController.php

示例6: actionCreate

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

示例7: store

 /**
  * Store a newly created car in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Car::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $car = new Car();
     $car->reg_no = Input::get('reg_no');
     $car->make = Input::get('make');
     $car->driver = Input::get('driver');
     $car->status = 'available';
     $car->driver_contact = Input::get('driver_contact');
     $car->save();
     return Redirect::route('cars.index');
 }
开发者ID:kenkode,项目名称:umash-1,代码行数:20,代码来源:CarsController.php

示例8: add

 public function add($data)
 {
     $uid = intval($data['uid']);
     $info = Car::findFirst("uid={$uid}");
     if (!$info) {
         $info = new Car();
         $info->addtime = time();
         $info->uid = $uid;
     }
     $info->uptime = time();
     foreach ($data as $field => $value) {
         $info->{$field} = $value;
     }
     $result = $info->save();
     if (!$result) {
         $this->outputErrors($info);
         return false;
     }
     return true;
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:20,代码来源:Car.php

示例9: setUpCarsAndDrivers

 public function setUpCarsAndDrivers()
 {
     Doctrine::createTablesFromArray(array('Car', 'Driver'));
     $bmw = new Car();
     $bmw->make = 'BMW';
     $bmw->save();
     $this->cars['bmw'] = $bmw;
     $audi = new Car();
     $audi->make = 'Audi';
     $audi->save();
     $this->cars['audi'] = $audi;
     $kiro = new Driver();
     $kiro->name = 'Kiril Zyapkov';
     $kiro->save();
     $this->drivers['kiro'] = $kiro;
     $emo = new Driver();
     $emo->name = 'Emil Ivanov';
     $emo->save();
     $this->drivers['emo'] = $emo;
 }
开发者ID:vladev,项目名称:zend-form-doctrine,代码行数:20,代码来源:RelationsTest.php

示例10: run

 public function run()
 {
     $user = User::firstOrFail();
     $car = new Car();
     $car->make = 'Toyota';
     $car->model = 'Prius';
     $car->license_plate_number = '4AQJ668';
     $car->color = 'Red';
     $car->user_id = $user->id;
     $car->save();
     $car2 = new Car();
     $car2->make = 'Hyundai';
     $car2->model = 'Genesis';
     $car2->license_plate_number = '6GDG486';
     $car2->color = 'Blue';
     $car2->user_id = $user->id;
     $car2->save();
     $car3 = new Car();
     $car3->make = 'BMW';
     $car3->model = 'X6';
     $car3->license_plate_number = 'G742594';
     $car3->color = 'White';
     $car3->user_id = $user->id;
     $car3->save();
     $car4 = new Car();
     $car4->make = 'Kia';
     $car4->model = 'Soul';
     $car4->license_plate_number = '2CJC569';
     $car4->color = 'Black';
     $car4->user_id = $user->id;
     $car4->save();
     $car5 = new Car();
     $car5->make = 'Ferrari';
     $car5->model = 'Testa Rossa';
     $car5->license_plate_number = 'BB1B001';
     $car5->color = 'Gray';
     $car5->user_id = $user->id;
     $car5->save();
 }
开发者ID:Park-It,项目名称:parkit.dev,代码行数:39,代码来源:CarsTableSeeder.php

示例11: storeCar

 public function storeCar()
 {
     $messages = array('make.required' => 'Make field cannot be left empty.', 'make.max' => 'You must enter a value with a maximum of 255 characters.', 'model.required' => 'Model field cannot be left empty.', 'model.max' => 'You must enter a value with a maximum of 255 characters.', 'license_plate_number.required' => 'License Plate Number field cannot be left empty.', 'license_plate_number.max' => 'You must enter a value with a maximum of 255 characters.', 'color.required' => 'Color field cannot be left empty.', 'color.max' => 'You must enter a value with a maximum of 255 characters.');
     $validator = Validator::make($data = Input::all(), Car::$rules, $messages);
     if ($validator->fails()) {
         return Response::json($validator->messages());
     }
     $car = new Car();
     $car->make = Input::get('make');
     $car->model = Input::get('model');
     $car->license_plate_number = Input::get('license_plate_number');
     $car->color = Input::get('color');
     if (Auth::check()) {
         $car->user_id = Auth::user()->id;
     }
     $result = $car->save();
     $order = new Order();
     $order->car_id = $car->id;
     $order->parking_lot_id = Input::get('hiddenParkingLot');
     $order->save();
     return Response::json(['success' => true]);
 }
开发者ID:Park-It,项目名称:parkit.dev,代码行数:22,代码来源:HomeController.php

示例12: array

//Twig Path
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
//Route and Controller
$app->get("/", function () use($app) {
    return $app['twig']->render('carsearch.html.twig');
});
//Gets the user input from add a car
$app->post("/added", function () use($app) {
    // $car_make = $_POST['car_make'];
    // $car_price = $_POST['car_price'];
    // $car_miles = $_POST['car_miles'];
    // $car_image = $_POST['car_image'];
    //$cars = Car::getAll();
    $newcar = array();
    $newcar = new Car($_POST['car_make'], $_POST['car_price'], $_POST['car_miles'], $_POST['car_image']);
    $newcar->save();
    //array_push($newcar, $cars);
    //$cars->save();
    return $app['twig']->render('addcar.html.twig', array('addedcar' => $newcar));
});
//$_POST['car_make'], $_POST['car_price'], $_POST['car_miles'], $_POST['car_image']
//   $added_car = array();
//   for($i = 0; $i < 10; $i++) {
//     $newcar = "newcar_$i";
//     $$newcar =
//     $added_car = array($newcar);
//     //$added_car->savecar();
//   }
//
//   $added_cars = Car::getAllCar();
//
开发者ID:kevintokheim,项目名称:Car_Dealership_2,代码行数:31,代码来源:app.php

示例13: testAddNewRecord

 /**
  * testAddNewRecord.
  *
  * Assert that the instantiated class is an instance of the Potato Model
  *
  * Assert that the save method adds a new [5th] record into the cars table
  *
  * For a new insert, the save method returns the ID of the inserted record
  */
 public function testAddNewRecord()
 {
     $car = new Car();
     $car->name = 'Bentley';
     $car->model = 'Mulsanne Range';
     $car->year = 2015;
     $carId = $car->save();
     $this->assertTrue($car instanceof PotatoModel);
     $this->assertEquals(5, $carId);
     $this->assertTrue($carId);
 }
开发者ID:johnkariuki,项目名称:checkpoint-two-potato-orm,代码行数:20,代码来源:PotatoModelTest.php

示例14: Car

$porsche = new Car("2014 Porsche 911", "images/porsche.jpg", 114991, 7864);
$ford = new Car("2011 Ford F450", "images/ford.jpg", 55995, 14241);
$lexus = new Car("2013 Lexus RC 350", "images/lexus.jpg", 44700, 20000);
$mercedes = new Car("Mercedes Benz CLS550", "images/mercedes.jpg", 39900);
if (empty($_SESSION['da_carz'])) {
    $_SESSION['da_carz'] = array($porsche, $ford, $lexus, $mercedes);
}
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('cars.html.twig');
});
$app->post("/list_car", function () use($app) {
    $new_car = new Car($_POST['make_model'], $_POST['picture'], $_POST['price'], $_POST['miles']);
    //in order to get the default value to be applied, i had to remove "$POST['miles']" entirely. so, it seems as if there's nothing to detect whether it is a value of zero or not, and what to do if that is not okay. check
    $new_car->save();
    echo "<pre>";
    print_r($new_car);
    echo "</pre><br>";
    return $app['twig']->render('list_car.html.twig', array('list_car' => $new_car));
});
$app->get("/car_lot", function () use($app) {
    return $app['twig']->render('car_lot.html.twig', array('autos' => Car::getAll()));
});
$app->get("/match_cars", function () use($app) {
    $cars = Car::getAll();
    $cars_matching_search = array();
    foreach ($cars as $car) {
        if ($car->worthBuying($_GET['max_price'], $_GET['max_miles'])) {
            array_push($cars_matching_search, $car);
        }
开发者ID:jmalo34,项目名称:car,代码行数:31,代码来源:app.php

示例15: saveChar

 protected function saveChar($model)
 {
     if (!($brand = Brand::model()->find('alias=:alias', array(':alias' => $model->brand_alias)))) {
         $brand = new Brand();
     }
     $brand->title = $model->brand;
     $brand->alias = $model->brand_alias;
     $brand->save();
     if (!empty($brand->errors)) {
         d('brand ' . $brand->title);
         d($brand->errors);
     }
     if (!($car = Car::model()->find('alias=:alias', array(':alias' => $model->model_alias)))) {
         $car = new Car();
     }
     $car->brand_id = $brand->id;
     $car->title = $model->model;
     $car->alias = $model->model_alias;
     $car->manufacture_start = $model->modificationManufactureStart . '0101';
     $car->manufacture_end = $model->modificationManufactureEnd ? $model->modificationManufactureEnd . '0101' : null;
     $car->save();
     if (!empty($car->errors)) {
         d('model ' . $car->title);
         d($car->errors);
     }
     if (!($mod = Modification::model()->find('alias=:alias', array(':alias' => $model->mod_alias)))) {
         $mod = new Modification();
     }
     $mod->model_id = $car->id;
     $mod->title = $model->mod;
     $mod->alias = $model->mod_alias;
     $mod->manufacture_start = $model->modificationManufactureStart . '0101';
     $mod->manufacture_end = $model->modificationManufactureEnd ? $model->modificationManufactureEnd . '0101' : null;
     $mod->save();
     if (!empty($mod->errors)) {
         d('mod ' . $mod->title);
         d($mod->errors);
     }
     if (!($char = Characteristic::model()->find('modification_id=:mod_id', array(':mod_id' => $mod->id)))) {
         $char = new Characteristic();
     }
     $char->attributes = $model->char->attributes;
     $char->modification_id = $mod->id;
     $char->save();
     if (!empty($char->errors)) {
         d('char ' . $mod->title);
         d($char->errors);
         d($model->url);
     }
 }
开发者ID:BGCX261,项目名称:zoomtyre-svn-to-git,代码行数:50,代码来源:DefaultController.php


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