當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Reservation::setAttributes方法代碼示例

本文整理匯總了PHP中Reservation::setAttributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP Reservation::setAttributes方法的具體用法?PHP Reservation::setAttributes怎麽用?PHP Reservation::setAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Reservation的用法示例。


在下文中一共展示了Reservation::setAttributes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testCreate

 public function testCreate()
 {
     $connection = Yii::app()->db;
     $sql = "delete from reservation";
     $command = $connection->createCommand($sql);
     $command->execute();
     $dateOverlapFromObj = new DateTime();
     $dateOverlapFrom = $dateOverlapFromObj->format('Y-m-d');
     $reservation = new Reservation();
     $reservation->setAttributes(array('roomid' => 1, 'datefrom' => $dateOverlapFrom, 'numberofnights' => 10, 'confirmreservation' => true));
     $id = $reservation->save();
     $reservationdetails = new Reservationdetails();
     $reservationdetails->setAttributes(array('reservationid' => $reservation->getAttribute('id'), 'title' => "Mr", 'firstname' => "John", 'lastname' => "Smith", 'contactnumber' => "0123456789", 'emailaddress' => "john.smith@blankemailaddress.blanky.co.uk", 'city' => "City", 'county' => "County", 'country' => "UK", 'postcode' => "ab12 4cd", 'postaddress' => 'Test postal address', 'otherinfo' => "Test"));
     $this->assertTrue($reservationdetails->save());
     return $reservationdetails;
 }
開發者ID:bogiesoft,項目名稱:YiiHotelReservation,代碼行數:16,代碼來源:ReservationDetailsTest.php

示例2: noReservationsAvailableCase5

 /**
  * Test to make sure a reservation with a datefrom greater than our existing reservation
  * and dateto after our existing reservations dateto cannot be made.
  * 
  * Original Reservation                      |---------------|
  * Case 5                                            |------------------|
  * 
  * @param Reservation $reservation
  * @depends testNoReservationsAvailable
  */
 public function noReservationsAvailableCase5($reservation)
 {
     $newDateFrom = new DateTime();
     $newDateFrom = DateTime::createFromFormat('Y-m-d', $this->_dateOverlapFromObj->format('Y-m-d'));
     $newDateFrom->add(new DateInterval('P1D'));
     $reservation = new Reservation();
     $reservation->setAttributes(array('roomid' => 1, 'datefrom' => $newDateFrom->format('Y-m-d'), 'numberofnights' => $this->_numberofnights + 1));
     $this->assertFalse($reservation->save());
 }
開發者ID:bogiesoft,項目名稱:YiiHotelReservation,代碼行數:19,代碼來源:ReservationTest.php


注:本文中的Reservation::setAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。