yiiframe如何计算座位

时间:2014-04-16 07:46:32

标签: php yii

我创建了一个名为screen的表。我有booked seatsseats作为列。我希望逐个递增booked seats,当booked seatsseats相等时,我想回显"tickets fulled"

 public function actionfulltickets($id)
 {
  $screen1=screen::model()->findByPk($id);
  $booked+=screen1.booked_seats;
  if(screen1.seats==screen1.booked_seats)
  {
  $info="tickets fulled";
  echo cjson::encode($info);
 }

1 个答案:

答案 0 :(得分:0)

public function actionfulltickets($id)
{
    $screen1=screen::model()->findByPk($id);
    // check have avaiable ticket or not.
    if(screen1->seats==screen1->booked_seats)
    {
       $info="tickets fulled";
       echo cjson::encode($info);
    } else {
       screen1->booked_seats++;
       screen1->save();
       $info="booked successful";
       echo cjson::encode($info);
    }
}

希望它可以帮到你。