本文整理匯總了PHP中Reservation::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Reservation::model方法的具體用法?PHP Reservation::model怎麽用?PHP Reservation::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Reservation
的用法示例。
在下文中一共展示了Reservation::model方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: populate
public function populate($roomType, $dates)
{
$this->roomType = $roomType;
foreach ($dates as $date) {
$criteria = new CDbCriteria();
$criteria->condition = ':date between dateFrom and dateTo
and roomid=:roomId
and confirmreservation=true';
$criteria->params = array(":date" => $date, ":roomId" => $this->roomType->id);
$result = Reservation::model()->findAll($criteria);
$this->reservations[$date] = $result;
}
}
示例2: testUpdate
/**
* Test we can update the reservation.
*/
public function testUpdate()
{
$this->resetReservationTable();
$this->resetDateTimes();
$reservation = new Reservation();
$reservation->setAttributes(array('roomid' => 1, 'datefrom' => $this->_dateOverlapFrom, 'numberofnights' => $this->_numberofnights));
$reservation->save(false);
$newDateTo = DateTime::createFromFormat('Y-m-d', $this->_dateOverlapToObj->format('Y-m-d'));
$newDateTo->add(new DateInterval('P10D'));
$reservation = Reservation::model()->findByPk($reservation->getAttribute('id'));
$reservation->setAttribute('dateto', $newDateTo->format('Y-m-d'));
$reservation->setAttribute('confirmreservation', true);
//must run validation rules
$this->assertTrue($reservation->save());
$reservation = Reservation::model()->findByPk($reservation->getAttribute('id'));
$this->assertEquals($newDateTo->format('Y-m-d'), $reservation->dateto);
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'payment' page.
*/
public function actionCreate()
{
$model = new ReservationDetails();
$model->reservation = Reservation::model()->findByPk(Yii::app()->session['reservationid']);
$model->reservation->setAttribute('confirmreservation', true);
if (isset($_POST['ReservationDetails'])) {
if ($model->reservation->save()) {
$model->attributes = $_POST['ReservationDetails'];
$model->setAttribute('reservationid', $model->reservation->id);
if ($model->save()) {
if (!Yii::app()->user->isGuest) {
$this->redirect(array('reservation/update', 'id' => $model->reservation->id));
} else {
$this->redirect(array('viewPayment'));
}
}
} else {
throw new CHttpException(500, 'Unable to save reservation');
}
}
$this->render('create', array('model' => $model));
}
示例4: actionCancel
public function actionCancel($id)
{
$reservation = Reservation::model()->findByPk($id);
if (isset($reservation)) {
$reservation->status = 'CANCELED';
$reservation->save();
}
$this->redirect(Yii::app()->request->getBaseUrl(true) . '#cuenta');
}
示例5: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Reservation::model()->findByPk((int) $id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}