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


PHP School::save方法代码示例

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


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

示例1: store

 public function store()
 {
     $school = new School();
     $school->city_id = Input::get('city');
     $school->name = Input::get('name');
     $school->address = Input::get('address');
     $school->contact = Input::get('contact');
     $school->contact_person = Input::get('contact_person');
     $school->level = Input::get('level');
     $school->save();
     Session::flash('message', 'Sukses menambahkan Sekolah Baru!');
 }
开发者ID:emanmks,项目名称:oneschool,代码行数:12,代码来源:SchoolsController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $school = new School();
     $school->name = $request->name;
     $school->address = $request->address;
     $school->state = $request->state;
     $school->zipcode = $request->zipcode;
     $school->country = $request->country;
     $school->save();
     return $school->toJson();
 }
开发者ID:purplenimbus,项目名称:Nimbus-SMS,代码行数:18,代码来源:SchoolController.php

示例3: actionCreate

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

示例4: createSchool

 public static function createSchool($domain, $schoolName, $contactName, $contactEmail, $password, $bgColor, $bgImg)
 {
     $newSchool = new School();
     $newSchool->domain = $domain;
     $newSchool->schoolName = $schoolName;
     $newSchool->contactName = $contactName;
     $newSchool->contactEmail = $contactEmail;
     $newSchool->contactPassword = sha1($password);
     $newSchool->bgColor = $bgColor;
     $newSchool->bgImg = $bgImg;
     $newSchool->save();
     return $newSchool;
 }
开发者ID:neojjang,项目名称:Sneffel,代码行数:13,代码来源:School.class.php

示例5: actionIndex

 public function actionIndex()
 {
     $this->bodyId = 'page-school';
     if (Yii::app()->request->isPostRequest) {
         $obj = array();
         //图片不存在
         if (!isset($_FILES['photo'])) {
             $obj['extra']['code'] = '400';
             exit(json_encode($obj));
         }
         //图片超过 2M
         $maxFileSize = Yii::app()->params['uploadMaxSize'] + 1;
         if ($_FILES['photo']['size'] > $maxFileSize) {
             $obj['extra']['code'] = '400';
             $obj['extra']['errors'] = ['photo' => '最大2M'];
             exit(json_encode($obj));
         }
         if (isset($_POST['project'])) {
             $_POST['project'] = json_encode($_POST['project']);
         }
         $school = new School();
         $school->attributes = $_POST;
         $school->photo = EEH::moveUploadFile($_FILES['photo'], Yii::app()->params['uploadPathImage'] . 'school_photo/');
         // 压缩图片
         $info = pathinfo($school->photo);
         $smallFile = Yii::app()->params['uploadPathImage'] . 'school_photo/' . $school->photo;
         $bigFile = Yii::app()->params['uploadPathImage'] . 'school_photo/' . $info['filename'] . '_origin.' . $info['extension'];
         $image = Yii::app()->image->load($smallFile);
         $image->save($bigFile);
         // 保存原文件
         $image->resize(Yii::app()->params['uploadMaxWidth'], Yii::app()->params['uploadMaxHeight'])->quality(Yii::app()->params['uploadQuality']);
         $image->save($smallFile);
         // 保存压缩后文件
         if (!$school->save()) {
             $obj['extra']['code'] = '400';
             foreach ($school->errors as $key => $value) {
                 $obj['extra']['errors'][$key] = $value;
             }
         } else {
             $obj['extra']['desc'] = '报名成功。';
             $obj['extra']['code'] = '200';
         }
         exit(json_encode($obj));
     }
     $this->render('index');
 }
开发者ID:CNAEF,项目名称:go9999_v2,代码行数:46,代码来源:SchoolController.php

示例6: storeKindergarten

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function storeKindergarten()
 {
     $data = Input::only('name', 'description', 'contacts', 'financing_id', 'district_id', 'city_id');
     $school = new School();
     $school->name = $data['name'];
     $school->type_id = '5';
     $school->description = $data['description'];
     $school->contacts = $data['contacts'];
     $school->cover_photo = Input::file('cover_photo');
     $school->financing_id = $data['financing_id'];
     $school->city_id = $data['city_id'];
     try {
         $school->save();
     } catch (ValidationException $errors) {
         return Redirect::route('admin.kindergartens.create')->withErrors($errors->getErrors())->withInput();
     }
     return Redirect::route('admin.kindergartens.create')->withErrors(array('mainSuccess' => 'Детската градина е успешно добавена.'));
 }
开发者ID:mertindervish,项目名称:registerbg,代码行数:23,代码来源:AdminSchoolController.php

示例7: 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->aSchool !== null) {
             if ($this->aSchool->isModified() || $this->aSchool->isNew()) {
                 $affectedRows += $this->aSchool->save($con);
             }
             $this->setSchool($this->aSchool);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->termsScheduledForDeletion !== null) {
             if (!$this->termsScheduledForDeletion->isEmpty()) {
                 TermQuery::create()->filterByPrimaryKeys($this->termsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->termsScheduledForDeletion = null;
             }
         }
         if ($this->collTerms !== null) {
             foreach ($this->collTerms as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:therealchiko,项目名称:getchabooks,代码行数:54,代码来源:BaseCampus.php

示例8: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if ($this->CanAccess('create')) {
         $model = new School();
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['School'])) {
             $model->attributes = $_POST['School'];
             if ($model->CanUpdate() && $model->save()) {
                 // if AJAX request , we should not redirect the browser
                 if (!Yii::app()->request->isAjaxRequest) {
                     $this->redirect(array('view', 'id' => $model->id));
                 } else {
                     // UNCOMMENT THIS IF YOU WANT TO RETURN ID OF THE NEWLY CREATED
                     // OBJECT (USEFUL WHEN CREATING NEW OBJECTS VIA AJAX AND INFO ABOUT
                     // THEN NEWLY CREATED OBJECT MUST BE SENT TO THE BROWSER)
                     // echo CJSON::encode(array('error' => '', 'id' => $model->id));
                     // die();
                 }
             } else {
                 throw new CHttpException(405, Yii::t('app', 'You do not have permissions to access this page.'));
             }
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->render('create', array('model' => $model));
             // IF YOU NEED DIFFERENT RENDERING FOR AJAX AND NON-AJAX CALLS,
             // USE THIS LINE AND DELETE THE LINE ABOVE
             // $this->render('create', array('model' => $model, 'ajaxRendering' => false));
         } else {
             throw new CHttpException(400, Yii::t('app', 'Bad request. The request cannot be fulfilled.'));
             // IF YOU NEED DIFFERENT RENDERING FOR AJAX AND NON-AJAX CALLS,
             // USE THIS LINE AND DELETE THE LINE ABOVE
             // $this->renderPartial('create', array('model' => $model, 'ajaxRendering' => true));
         }
     } else {
         throw new CHttpException(405, Yii::t('app', 'You do not have permissions to access this page.'));
     }
 }
开发者ID:lidijakralj,项目名称:bober,代码行数:42,代码来源:SchoolController.php

示例9: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $school = new School();
     $school->name = 'cool school';
     $school->save();
     $group = new Group();
     $group->name = 'Admin';
     $group->school_id = $school->id;
     $group->password = "pass";
     $group->save();
     $user = new User();
     $user->name = 'Alex Leung';
     $user->email = 'alex.l.leung@gmail.com';
     $user->group_id = $group->id;
     $user->password = Hash::make("alexpass");
     $user->save();
     $user = new User();
     $user->name = 'Krishang Swami';
     $user->email = '12butts@gmail.com';
     $user->group_id = $group->id;
     $user->password = Hash::make("krishpass");
     $user->save();
 }
开发者ID:AlexLeung,项目名称:ibsurvey,代码行数:28,代码来源:seedUsersInitial.php

示例10: addAction

 public function addAction()
 {
     try {
         $name = Input::get('name');
         $description = Input::get('description');
         $address = Input::get('address');
         $publish = Input::get('publish');
         $school = new School();
         $school->name = $name;
         $school->description = $description;
         $school->address = $address;
         $school->published = $publish;
         $school->save();
         $id = DB::getPdo()->lastInsertId();
         $schools = explode(',', $school);
         //Session::put('id', $id);
         Session::flash('status_success', 'Successfully Updated.');
         return Redirect::route('admin/schoolEdit', array('id' => $id));
         //return Redirect::route('admin/classEdit');
     } catch (Exception $ex) {
         echo $ex;
         Session::flash('status_error', '');
     }
 }
开发者ID:AxelPardemann,项目名称:E-Learning-System-based-on-Laravel-and-Bootstrap,代码行数:24,代码来源:SchoolController.php

示例11: function

 $app->get('/', function () use($app, $data) {
     $data['schools'] = School::with('User')->orderBy('name', 'ASC')->get()->toArray();
     $app->render('schools/overview.html', $data);
 })->name('schools_overview');
 $app->map('/delete/:id', function ($id) use($app, $data) {
     $data['school'] = School::find($id);
     if ($app->request->isPost()) {
         $data['school']->delete();
     }
     $app->render('schools/delete.html', $data);
 })->via('GET', 'POST')->name('schools_delete');
 $app->map('/new', function () use($app, $data) {
     if ($app->request->isPost()) {
         $school = new School();
         $school->name = $app->request->post('name');
         $school->save();
         $data['new_school'] = $school;
     }
     $app->render('schools/new.html', $data);
 })->via('GET', 'POST')->name('schools_new');
 $app->map('/edit/:id', function ($id) use($app, $data) {
     $data['request_method'] = $app->request->getMethod();
     $school = School::find($id);
     if ($app->request->isGet()) {
         $data['school'] = $school->toArray();
     } else {
         if ($app->request->isPost()) {
             $school->name = $app->request->post('name');
             $school->save();
             $data['new_school'] = $school->toArray();
         }
开发者ID:Robinwist,项目名称:UXDTalentenTest,代码行数:31,代码来源:admin.php

示例12: postregister

 public function postregister()
 {
     $rules = array('state' => 'required', 'city' => 'required', 'other_city' => 'required_if:city,other', 'centre' => 'required_if:city,other', 'school' => 'required', 'name' => "required_if:school,other|string", 'addr1' => 'required_if:school,other', 'pincode' => 'required_if:school,other|digits:6', 'contact' => 'required_if:school,other', 'squad' => 'required', 'language' => 'required', 'name1' => "required|Regex:/^[\\p{L} .'-]+\$/", 'email1' => 'required|email', 'contact1' => 'required|numeric', 'name2' => "required|Regex:/^[\\p{L} .'-]+\$/", 'email2' => 'required|email', 'contact2' => 'required|numeric');
     $messages = array('name.regex' => 'School name can have words, commas, dashes, single quotes and dots.', 'pincode.digits' => 'Pincode can have exactly 6 digits.', 'contact.numeric' => 'School contact can have only digits.', 'name1.regex' => 'Name of Particpant 1 can have words, commas, dashes, single quotes and dots.', 'contact1.numeric' => 'Contact of Participant 1 can have only digits.', 'email1.email' => 'Email ID of Participant 1 has to be a valid email address.', 'name2.regex' => 'Name of Particpant 2 can have words, commas, dashes, single quotes and dots.', 'contact2.numeric' => 'Contact of Participant 2 can have only digits.', 'email2.email' => 'Email ID of Participant 2 has to be a valid email address.');
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         Input::flash();
         return Redirect::to('register')->withErrors($validator)->withInput();
     } else {
         if (Input::get('city') === 'other') {
             $city = new City();
             $city->name = ucwords(strtolower(Input::get('other_city')));
             $city->state_id = Input::get('state');
             $state = State::where('id', Input::get('state'))->first();
             $city->region = $state->region;
             //                $code=City::where('region', $state->region)->orderBy('code', 'desc')->first();
             //                $city->code=($code->code) + 1;
             $city->save();
             $cities = City::where('name', Input::get('other_city'))->orderBy('id', 'desc')->first();
             $city = $cities->id;
         } else {
             $city = Input::get('city');
         }
         if (Input::get('centre') !== "") {
             $centre = Input::get('centre') * 10;
         } else {
             $centre = $city * 10;
         }
         if (Input::get('school') === 'other') {
             $school = new School();
             $school->name = strtoupper(Input::get('name'));
             $school->address = strtoupper(Input::get('addr1') . ', ' . Input::get('addr2'));
             $school->pincode = Input::get('pincode');
             $school->contact = Input::get('contact');
             $school->email = Input::get('email');
             $school->city_id = $city;
             $school->save();
             $schools = School::where('name', Input::get('name'))->orderBy('id', 'desc')->first();
             $school = $schools->id;
         } else {
             $school = Input::get('school');
         }
         $user = new User();
         $user->name1 = strtoupper(Input::get('name1'));
         $user->email1 = Input::get('email1');
         $user->contact1 = Input::get('contact1');
         $user->name2 = strtoupper(Input::get('name2'));
         $user->email2 = Input::get('email2');
         $user->contact2 = Input::get('contact2');
         $user->squad = Input::get('squad');
         $user->school_id = $school;
         $user->language = Input::get('language');
         $user->city_id = $city;
         $user->centre_id = $centre;
         $roll = "";
         if (Input::get('squad') === 'JUNIOR') {
             $roll = "J";
         } else {
             $roll = "H";
         }
         if (Input::get('language') === 'en') {
             $roll .= "E";
         } else {
             $roll .= "H";
         }
         $centre_id = City::where('id', $centre / 10)->orderBy('id')->first();
         //            $code=$centre_id->id;
         $roll .= $centre_id->code;
         $roll .= 1;
         $lastroll = User::withTrashed()->where('roll', 'LIKE', "%{$roll}%")->count();
         $roll .= str_pad(strval($lastroll + 1), 4, "0", STR_PAD_LEFT);
         $user->roll = $roll;
         $user->year = 2015;
         $password = str_random(6);
         $user->password = Hash::make($password);
         $user->save();
         $school = School::find($user->school_id);
         $city = City::find($user->city_id);
         $state = State::find($city->state_id);
         Mail::send('emails.registered', array('user' => $user, 'school' => $school, 'city' => $city, 'state' => $state, 'password' => $password, 'name' => $user->name1), function ($message) use($user) {
             $message->to($user->email1, $user->name1)->subject('Technothlon Registration Details');
         });
         Mail::send('emails.registered', array('user' => $user, 'school' => $school, 'city' => $city, 'state' => $state, 'password' => $password, 'name' => $user->name2), function ($message) use($user) {
             $message->to($user->email2, $user->name2)->subject('Technothlon Registration Details');
         });
         Input::flush();
         //            return Redirect::route('home');
         return View::make('layouts.registersuccess')->with('user', $user);
     }
 }
开发者ID:aneeshdash,项目名称:technothlon-2015,代码行数:90,代码来源:HomeController.php

示例13: import

 public function import($content)
 {
     $header_cols = array('name' => 0, 'school_category_id' => 1, 'level_of_education' => 2, 'post' => 3, 'postal_code' => 4, 'municipality_id' => 5, 'region_id' => 6, 'country_id' => 7);
     header('Content-Type: text/html; charset=utf-8');
     $lines = explode("\n", $content);
     for ($i = 1; $i < count($lines); ++$i) {
         if (trim($lines[$i]) == '') {
             continue;
         }
         $cols = explode(";", $lines[$i]);
         // država
         $country_id = 0;
         $country = Country::model()->find('country=:country', array(':country' => trim($cols[$header_cols['country_id']])));
         if ($country == null) {
             echo Yii::t('app', 'Country does not exist! Country: ') . trim($cols[$header_cols['country_id']]);
             die;
         }
         $country_id = $country->id;
         // regija
         $region = Region::model()->find('name=:name and country_id=:country_id', array(':name' => trim($cols[$header_cols['region_id']]), ':country_id' => $country_id));
         if ($region == null) {
             $region = new Region();
             $region->country_id = $country_id;
             $region->name = trim($cols[$header_cols['region_id']]);
             $region->save();
         }
         $region_id = $region->id;
         // občina
         $municipality = Municipality::model()->find('name=:name and country_id=:country_id', array(':name' => trim($cols[$header_cols['municipality_id']]), ':country_id' => $country_id));
         if ($municipality == null) {
             $municipality = new Municipality();
             $municipality->country_id = $country_id;
             $municipality->name = trim($cols[$header_cols['municipality_id']]);
             $municipality->save();
         }
         $municipality_id = $municipality->id;
         $school_name = trim($cols[$header_cols['name']]);
         if ($school_name[0] == '"') {
             $school_name = mb_substr($school_name, 1, mb_strlen($school_name, 'UTF-8') - 2, 'UTF-8');
         }
         $school_name = str_replace('""', '"', $school_name);
         $school = School::model()->find('name=:name and country_id=:country_id', array(':name' => $school_name, ':country_id' => $country_id));
         if ($school == null) {
             $school = new School();
             $school->name = $school_name;
             $school->country_id = $country_id;
             $school->municipality_id = $municipality_id;
             $school->region_id = $region_id;
             $school->post = trim($cols[$header_cols['post']]);
             $school->postal_code = trim($cols[$header_cols['postal_code']]);
             $school->school_category_id = (int) trim($cols[$header_cols['school_category_id']]);
             $school->level_of_education = (int) trim($cols[$header_cols['level_of_education']]);
             $school->save();
             echo 'Imported: ', $school_name, "<br />\n";
             if (count($school->errors) > 0) {
                 print_r($school->errors);
                 die;
             }
         } else {
             echo 'Already imported: ', $school_name, "<br />\n";
         }
     }
 }
开发者ID:lidijakralj,项目名称:bober,代码行数:63,代码来源:School.php

示例14: SyncZavodiWhereKategorijaActive

 public static function SyncZavodiWhereKategorijaActive()
 {
     $schoolCategories = SchoolCategory::model()->findAll('active=:active', array(':active' => 1));
     $kategorije = array();
     $kategorija_map = array();
     foreach ($schoolCategories as $schoolCategory) {
         $kategorije[] = $schoolCategory->name;
         $kategorija_map[$schoolCategory->name] = $schoolCategory->id;
     }
     echo "Current categories for sync:<br />";
     pre_print($kategorije);
     $list = self::GetRegZavod();
     if (!isset($list['return'])) {
         return array();
     }
     $list = $list['return'];
     echo "Current schools to sync:<br />";
     $country = Country::model()->find('country=:country', array(':country' => 'Slovenija'));
     if ($country == null) {
         echo "Add country Slovenija!<br />\n";
         die;
     }
     $country_id = $country->id;
     // cache all občine
     $municipalities = Municipality::model()->findAll('country_id=:country_id', array(':country_id' => $country_id));
     $municipality_map = array();
     foreach ($municipalities as $municipality) {
         $municipality_map[$municipality->name] = $municipality->id;
     }
     // cache all regije
     $regions = Region::model()->findAll('country_id=:country_id', array(':country_id' => $country_id));
     $region_map = array();
     foreach ($regions as $region) {
         $region_map[$region->name] = $region->id;
     }
     $counter = 0;
     $updated = 0;
     $inserted = 0;
     for ($i = 0; $i < count($list); ++$i) {
         if (in_array($list[$i]['KATEGORIJA'], $kategorije)) {
             $counter++;
             $el = $list[$i];
             $school = School::model()->find('name=:name and country_id=:country_id', array(':name' => trim($el['ZAVOD_NAZIV']), ':country_id' => $country_id));
             if ($school == null) {
                 $school = new School();
                 $school->name = trim($el['ZAVOD_NAZIV']);
                 $school->country_id = $country_id;
                 $inserted++;
             }
             $school->school_category_id = $kategorija_map[trim($el['KATEGORIJA'])];
             // občina
             if (!isset($municipality_map[trim($el['OBCINANAZIV'])])) {
                 $municipality = new Municipality();
                 $municipality->name = trim($el['OBCINANAZIV']);
                 $municipality->country_id = $country_id;
                 $municipality->save();
                 $municipality_map[trim($el['OBCINANAZIV'])] = $municipality->id;
             }
             $school->municipality_id = $municipality_map[trim($el['OBCINANAZIV'])];
             // regija
             if (!isset($region_map[trim($el['REGIJANAZIV'])])) {
                 $region = new Region();
                 $region->name = trim($el['REGIJANAZIV']);
                 $region->country_id = $country_id;
                 $region->save();
                 $region_map[trim($el['REGIJANAZIV'])] = $region->id;
             }
             $school->region_id = $region_map[trim($el['REGIJANAZIV'])];
             $school->post = trim($el['POSTANAZIV']);
             $school->postal_code = trim($el['POSTASIFRA']);
             $school->identifier = trim($el['ZAVPRS']);
             $school->headmaster = trim($el['ZAVRAVN']);
             if (isset($el['ZAVDAVST'])) {
                 $school->tax_number = trim($el['ZAVDAVST']);
             }
             if ($school->save()) {
                 $updated++;
             }
         }
     }
     echo 'Found schools to sync: ', $counter, "<br />\n";
     echo 'New schools imported: ', $inserted, "<br />\n";
     echo 'Updated schools: ', $updated - $inserted, "<br />\n";
 }
开发者ID:lidijakralj,项目名称:bober,代码行数:84,代码来源:RegisterZavodov.php

示例15: updateSchoolDataArray

 /** 
  * Assuming there exists an activerecord array
  */
 public function updateSchoolDataArray($arObject, $collectionName, $collectionClassName, $itemCount, $arryUpdateFields, $req)
 {
     //$arryRecords=array();
     // Loop once for each array item to be added
     for ($index = 1; $index < $itemCount + 1; $index++) {
         foreach ($arryUpdateFields as $fieldName) {
             $indexedFieldname = $fieldName . $index;
             $indexedValue = $req[$indexedFieldname];
             //print("ADDing $fieldName => $indexedValue<p>");
             $arryUpdates[$fieldName] = $indexedValue;
             //var_dump($indexedValue);
         }
         if (strlen($arryUpdates['school_name']) > 0) {
             $arryRecords[] = $arryUpdates;
         }
     }
     //print("Creating these records<p>");
     //var_dump($arryRecords);
     // Delete all existing associations
     $colClass = new $collectionClassName();
     $colClass->delete_all("user_id=" . $this->uid);
     //create and add new school items
     foreach ($arryRecords as $record) {
         $newArryRecords[] = new $collectionClassName($record);
     }
     // We can't save these school items unless they have school_id's
     // So we must either lookup or create new ones
     $count = 0;
     foreach ($newArryRecords as $userProfEduItem) {
         $schoolName = $userProfEduItem->school_name;
         $school = new School();
         //print("Query For: "."name='$schoolName' and school_type='".$arryRecords[$count]['attended_for']."'");
         $school = $school->find_first("name='{$schoolName}' and school_type='" . $arryRecords[$count]['attended_for'] . "'");
         if ($school == null) {
             $school = new School(array('school_type' => $arryRecords[$count]['attended_for'], 'name' => $schoolName));
             $school->save();
             $school = $school->find_first("name='{$schoolName}' and school_type='" . $arryRecords[$count]['attended_for'] . "'");
         }
         // Now a school exists and we can update the Edu Item
         $userProfEduItem->school_id = $school->id;
         $count++;
     }
     // Now save our user prof items
     $arObject->{$collectionName} = $newArryRecords;
     return $arObject->save();
 }
开发者ID:jkinner,项目名称:ringside,代码行数:49,代码来源:ProfileApp.php


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