当前位置: 首页>>代码示例>>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;未经允许,请勿转载。