本文整理汇总了PHP中Room::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Room::save方法的具体用法?PHP Room::save怎么用?PHP Room::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _add
private function _add()
{
use_helper('Validate');
$data = $_POST['room'];
Flash::set('room_postdata', $data);
// Add pre-save checks here
$errors = false;
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL . 'room/add')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('room/add'));
}
} else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('room/add'));
}
if (empty($data['name'])) {
Flash::set('error', __('You have to specify a room name!'));
redirect(get_url('room/add'));
}
if ($errors !== false) {
// Set the errors to be displayed.
Flash::set('error', implode('<br/>', $errors));
redirect(get_url('room/add'));
}
$new_room = new Room($data);
$new_room->created_by_id = AuthUser::getId();
$new_room->created_on = date('Y-m-d H:i:s');
if ($new_room->save()) {
if (isset($_FILES)) {
if (strlen($_FILES['upload_file']['name']) > 0 || strlen($_FILES['upload_file_home']['name']) > 0) {
$room_id = $new_room->lastInsertId();
$overwrite = false;
if (strlen($_FILES['upload_file']['name']) > 0) {
$file = $this->upload_pdf_file($room_id, $_FILES['upload_file']['name'], FILES_DIR . '/room/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
}
if (strlen($_FILES['upload_file_home']['name']) > 0) {
$file2 = $this->upload_pdf_file2($room_id, $_FILES['upload_file_home']['name'], FILES_DIR . '/room/images/', $_FILES['upload_file_home']['tmp_name'], $overwrite);
}
if ($file === false || $file2 === false) {
Flash::set('error', __('File has not been uploaded1!'));
}
redirect(get_url('room/edit/' . $new_room->id));
}
}
Flash::set('success', __('Room has been added!'));
Observer::notify('room_after_add', $new_room->name);
// save and quit or save and continue editing?
if (isset($_POST['commit'])) {
redirect(get_url('room'));
} else {
redirect(get_url('room/edit/' . $new_room->id));
}
} else {
Flash::set('error', __('Room has not been added!'));
redirect(get_url('room/add'));
}
}
示例2: post_new
public function post_new()
{
$rules = array('title' => 'required|min:5|max:128', 'street' => 'required', 'postalcode' => 'required|match:#^[1-9][0-9]{3}\\h*[A-Z]{2}$#i', 'city' => 'required', 'type' => 'required', 'surface' => 'required|integer', 'price' => 'required|numeric|max:1500|min:100', 'date' => 'required|after:' . date('d-m-Y'), 'pictures' => 'required|image|max:3000', 'register' => 'required', 'email' => 'required|email|same:email2', 'description' => 'required|min:30', 'captchatest' => 'laracaptcha|required', 'terms' => 'accepted');
$v = Validator::make(Input::all(), $rules, Room::$messages);
if ($v->fails()) {
return Redirect::to('kamer-verhuren')->with_errors($v)->with('msg', '<div class="alert alert-error"><strong>Verplichte velden zijn niet volledig ingevuld</strong><br />Loop het formulier nogmaals na.</div>')->with_input();
} else {
if (Auth::check()) {
$status = 'publish';
} else {
$status = 'pending';
}
$new_room = array('title' => ucfirst(Input::get('title')), 'street' => ucwords(Input::get('street')), 'housenr' => Input::get('housenr'), 'postalcode' => Input::get('postalcode'), 'city' => ucwords(Input::get('city')), 'type' => Input::get('type'), 'surface' => Input::get('surface'), 'price' => Input::get('price'), 'available' => date("Y-m-d", strtotime(Input::get('date'))), 'gender' => Input::get('gender'), 'pets' => Input::get('pets'), 'smoking' => Input::get('smoking'), 'toilet' => Input::get('toilet'), 'shower' => Input::get('shower'), 'kitchen' => Input::get('kitchen'), 'register' => Input::get('register'), 'social' => Input::get('social'), 'email' => strtolower(Input::get('email')), 'description' => ucfirst(Input::get('description')), 'status' => $status, 'url' => Str::slug(Input::get('city')), 'delkey' => Str::random(32, 'alpha'), 'del_date' => date('y-m-d', strtotime('+2 months')));
$room = new Room($new_room);
if ($room->save()) {
$upload_path = path('public') . Photo::$upload_path_room . $room->id;
if (!File::exists($upload_path)) {
File::mkdir($upload_path);
chmod($upload_path, 0777);
}
$photos = Photo::getNormalizedFiles(Input::file('pictures'));
foreach ($photos as $photo) {
$filename = md5(rand()) . '.jpg';
$path_to_file = $upload_path . '/' . $filename;
$dynamic_path = '/' . Photo::$upload_path_room . $room->id . '/' . $filename;
$success = Resizer::open($photo)->resize(800, 533, 'auto')->save($path_to_file, 80);
chmod($path_to_file, 0777);
if ($success) {
$new_photo = new Photo();
$new_photo->location = $dynamic_path;
$new_photo->room_id = $room->id;
$new_photo->save();
}
}
Message::send(function ($message) use($room) {
$message->to($room->email);
$message->from('kamers@kamergenood.nl', 'Kamergenood');
$message->subject('In afwachting op acceptatie: "' . $room->title . '"');
$message->body('view: emails.submit');
$message->body->id = $room->id;
$message->body->title = $room->title;
$message->body->price = $room->price;
$message->body->type = $room->type;
$message->body->surface = $room->surface;
$message->body->available = $room->available;
$message->body->description = $room->description;
$message->body->url = $room->url;
$message->body->delkey = $room->delkey;
$message->html(true);
});
if (Message::was_sent()) {
return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-success"><strong>Hartelijk dank voor het vertrouwen in Kamergenood!</strong> De kameradvertentie zal binnen 24 uur worden gecontroleerd en geplaatst.</div>');
}
} else {
return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-error"><strong>Er is iets mis gegaan bij het toevoegen.</strong> Probeer het later nog eens.</div>')->with_input();
}
}
}
示例3: store
public function store()
{
$room = new Room();
$room->location_id = Input::get('location');
$room->name = Input::get('name');
$room->capacity = Input::get('capacity');
$room->save();
Session::flash('message', 'Sukses menambahkan ruangan baru!');
}
示例4: actionCreate
/**
* Создает новую модель Комнаты.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @return void
*/
public function actionCreate()
{
$model = new Room();
if (Yii::app()->getRequest()->getPost('Room') !== null) {
$model->setAttributes(Yii::app()->getRequest()->getPost('Room'));
if ($model->save()) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('BranchModule.branch', 'Запись добавлена!'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
}
}
$this->render('create', ['model' => $model]);
}
示例5: createRoom
public function createRoom($data)
{
$result = new Room();
$result->createTime = date('Y-m-d H:i:s', time());
foreach ($data as $k => $v) {
$result->{$k} = $v;
}
if ($result->save()) {
$data = array('code' => 200, 'message' => 'SUCCESS');
}
return $data;
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Room();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Room'])) {
$model->attributes = $_POST['Room'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->ID));
}
}
$this->render('create', array('model' => $model));
}
示例7: createRoom
public function createRoom($buildingid)
{
//count position
$position = count(Room::where('building_id', '=', $buildingid)->get()) + 1;
$room = new Room();
$room->name = Input::get("roomname");
$room->position = $position;
$room->building_id = $buildingid;
$room->save();
//fetch created id
$id = $room->id;
return Redirect::to('/building/' . $buildingid . '/' . $id);
}
示例8: executeAdd
public function executeAdd(sfWebRequest $request)
{
if ($request->isMethod('Post')) {
$room = new Room();
$room->setTitle($this->getRequestParameter('title'));
$room->setPrice($this->getRequestParameter('price'));
$room->setStatus(Constant::BED_AVAILABLE);
$room->save();
$this->getUser()->setFlash('SUCCESS_MESSAGE', Constant::RECORD_ADDED_SUCCESSFULLY);
$this->redirect('Room/list');
}
//end if
}
示例9: 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->aRoom !== null) {
if ($this->aRoom->isModified() || $this->aRoom->isNew()) {
$affectedRows += $this->aRoom->save($con);
}
$this->setRoom($this->aRoom);
}
if ($this->isNew()) {
$this->modifiedColumns[] = RoomprofilePeer::ID;
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = RoomprofilePeer::doInsert($this, $con);
$affectedRows += 1;
// we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setId($pk);
//[IMV] update autoincrement primary key
$this->setNew(false);
} else {
$affectedRows += RoomprofilePeer::doUpdate($this, $con);
}
$this->resetModified();
// [HL] After being saved an object is no longer 'modified'
}
if ($this->collReservations !== null) {
foreach ($this->collReservations as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例10: showCreateRoomPage
private function showCreateRoomPage()
{
if (WebRequest::wasPosted()) {
try {
// get variables
$rname = WebRequest::post("rname");
$rtype = WebRequest::postInt("rtype");
$rmin = WebRequest::postInt("rmin");
$rmax = WebRequest::postInt("rmax");
$rprice = WebRequest::postFloat("rprice");
// data validation
if ($rname == "") {
throw new CreateRoomException("blank-roomname");
}
if ($rtype == 0) {
throw new CreateRoomException("blank-roomtype");
}
if ($rmax < 1 || $rmin < 0) {
throw new CreateRoomException("room-capacity-too-small");
}
if ($rmin > $rmax) {
throw new CreateRoomException("room-capacity-min-gt-max");
}
if ($rprice != abs($rprice)) {
throw new CreateRoomException("room-price-negative");
}
$room = new Room();
// set values
$room->setName($rname);
$room->setType($rtype);
$room->setMinPeople($rmin);
$room->setMaxPeople($rmax);
$room->setPrice($rprice);
$room->save();
global $cScriptPath;
$this->mHeaders[] = "Location: {$cScriptPath}/Rooms";
} catch (CreateRoomException $ex) {
$this->mBasePage = "mgmt/roomCreate.tpl";
$this->error($ex->getMessage());
}
} else {
$this->mBasePage = "mgmt/roomCreate.tpl";
}
$this->mSmarty->assign("rtlist", RoomType::$data);
}
示例11: actionAdd_room
public function actionAdd_room()
{
$room = new Room();
$room->style = $_POST['style'];
$room->content = $_POST['content'];
$room->company = $_POST['company'];
if (isset($_POST['source'])) {
$room->source = $_POST['source'];
}
if (isset($_POST['thumb'])) {
$room->thumb = $_POST['thumb'];
}
$room->boat = $_POST['boat'];
$room->save();
//$this->redirect(Yii::app()->request->urlReferrer);
echo 1;
// echo CJSON::encode(array('title'=>$_POST['title'], 'area'=>$_POST['area'], 'port'=>$_POST['port']));//Yii 的方法将数组处理成json数据
}
示例12: actionCreate
/**
* Создает новую модель Аудитории.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @return void
*/
public function actionCreate()
{
$roles = ['1'];
$role = \Yii::app()->user->role;
if (array_intersect($role, $roles)) {
$model = new Room();
if (Yii::app()->getRequest()->getPost('Room') !== null) {
$model->setAttributes(Yii::app()->getRequest()->getPost('Room'));
if ($model->save()) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('BranchModule.branch', 'Запись добавлена!'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
}
}
$this->render('create', ['model' => $model]);
} else {
throw new CHttpException(403, 'Ошибка прав доступа.');
}
}
示例13: setup
protected function setup()
{
$loggedUser = LoggedUser::whoIsLogged();
if (Utils::post('create_room') && $loggedUser['admin']) {
$params = array('title' => Utils::post('title'), 'alias' => Utils::createAlias(Utils::post('title'), 'room'), 'description' => Utils::post('description'));
$room = new Room($params);
$room->save();
}
$roomRepository = new RoomRepository();
$rooms = $roomRepository->getAll();
$gameRepository = new GameRepository();
$games = $gameRepository->getGamesByRooms(array_keys($rooms));
foreach ($games as $game) {
$rooms[$game['room']]['game'] = TRUE;
$rooms[$game['room']]['status'] = Localize::getMessage('room_status_' . $game['status']);
}
MySmarty::assign('loggedUser', $loggedUser);
MySmarty::assign('rooms', $rooms);
}
示例14: run
public function run()
{
$faker = Faker\Factory::create();
DB::table('groups')->delete();
DB::table('rooms')->delete();
DB::table('users')->delete();
$group = new Group();
$group->name = "Admin";
$group->permission = "1,2,3,4,5,6";
$group->admin = true;
$group->save();
$group = new Group();
$group->name = "Customer";
$group->permission = "10";
$group->admin = false;
$group->save();
for ($i = 1; $i < 10; $i++) {
$room = new Room();
$room->room_code = sprintf("%03dS", $i);
$room->save();
}
$admin_group = Group::where('name', '=', 'Admin')->first();
$customer_group = Group::where('name', '=', 'Customer')->first();
$user = new User();
$user->username = "admin";
$user->password = Hash::make("passnhulon");
$user->group_id = $admin_group->id;
$user->realname = "Sairen Nguyen";
$user->birthday = "1993-04-05";
$user->email = "t3ngcu00@students.oamk.fi";
$user->save();
for ($i = 1; $i < 10; $i++) {
$user = new User();
$user->username = sprintf("%03dS", $i);
$user->password = Hash::make("passnhulon");
$user->group_id = $customer_group->id;
$user->room_id = Room::all()->first()->id + $i - 1;
$user->realname = $faker->name();
$user->email = $faker->email;
$user->save();
}
}
示例15: doSave
/**
* Stores the object 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 Connection $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($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->aUser !== null) {
if ($this->aUser->isModified()) {
$affectedRows += $this->aUser->save($con);
}
$this->setUser($this->aUser);
}
if ($this->aRoom !== null) {
if ($this->aRoom->isModified()) {
$affectedRows += $this->aRoom->save($con);
}
$this->setRoom($this->aRoom);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = PermissionPeer::doInsert($this, $con);
$affectedRows += 1;
// we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setNew(false);
} else {
$affectedRows += PermissionPeer::doUpdate($this, $con);
}
$this->resetModified();
// [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
}