我有一个数据库,将座位号存储在单列中。如何从给定数据中以json格式检索这些座位号,这些数据作为参数$ tripIdNo,$ fleetRegNo,$ newSeats发送... 我已经尝试过了,但是没有成功
private function checkBooking($tripIdNo = null, $fleetRegNo = null, $newSeats = null)
{
//---------------fleet seats----------------
$fleetSeats = $this->db->select("
total_seat, seat_numbers, fleet_facilities
")->from("fleet_registration")
->where('reg_no', $fleetRegNo)
->get()
->row();
$seatArray = array();
$seatArray = array_map('trim', explode(',', $fleetSeats->seat_numbers));
//-----------------booked seats-------------------
$bookedSeats = $this->db->select("
tb.trip_id_no,
SUM(tb.total_seat) AS booked_seats,
GROUP_CONCAT(tb.seat_numbers SEPARATOR ', ') AS booked_serial
")
->from('tkt_booking AS tb')
->where('tb.trip_id_no', $tripIdNo)
->group_start()
->where("tb.tkt_refund_id IS NULL", null, false)
->or_where("tb.tkt_refund_id", 0)
->or_where("tb.tkt_refund_id", null)
->group_end()
->get()
->row();
$bookArray = array();
$bookArray = array_map('trim', explode(',', $bookedSeats->booked_serial));
//-----------------booked seats-------------------
$newSeatArray = array();
$newSeatArray = array_map('trim', explode(',', $newSeats));
if (sizeof($newSeatArray) > 0) {
foreach ($newSeatArray as $seat) {
if (!empty($seat)) {
if (in_array($seat, $bookArray)) {
return false;
} else if (!in_array($seat, $seatArray)) {
return false;
}
}
}
return true;
} else {
return false;
}
}
我已经附上了数据库的图像。从那两个表中,分别是trip_booking和Fleet_registration。关于此问题的任何建议。