我创建了一个名为screen
的表。我有booked seats
和seats
作为列。我希望逐个递增booked seats
,当booked seats
和seats
相等时,我想回显"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);
}
答案 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);
}
}
希望它可以帮到你。