I have a multi-dimensional array $rows
which return the result like below; I have created queries based on array_keys. Now the problem I am facing is $rows may or may not return some of the rows if there is no vacant beds and all my queries goes for a toss.
I have tried to use in_array
function, but it appears this doens't work with multi-dimensional array.
array (size=6)
0 =>
array (size=2)
'room_category' => string 'MALE GENERAL WARD' (length=17)
'vacant_beds' => string 'MG-5' (length=4)
1 =>
array (size=2)
'room_category' => string 'FEMALE GENERAL WARD' (length=19)
'vacant_beds' => string 'FG-2,FG-3,FG-4' (length=14)
2 =>
array (size=2)
'room_category' => string 'MOTHER CHILD WARD' (length=17)
'vacant_beds' => string 'MC-1,MC-3,MC-4' (length=14)
3 =>
array (size=2)
'room_category' => string 'NICU' (length=4)
'vacant_beds' => string 'NICU-8,NICU-4,NICU-5,NICU-6,NICU-1,NICU-7,NICU-2' (length=48)
4 =>
array (size=2)
'room_category' => string 'CLASSIC' (length=7)
'vacant_beds' => string 'CL-9,CL-4,CL-5,CL-7,CL-8' (length=24)
5 =>
array (size=2)
'room_category' => string 'DELUXE' (length=6)
'vacant_beds' => string 'DLX-6,DLX-3,DLX-4,DLX-5' (length=23)
What approach I should take or ensure that it returns a row even if a specific ward is not vacant.
My code for $rows is like this:
select `rct`.`room_category` AS `room_category`,
group_concat(`rn`.`room_name` separator ',') AS `vacant_beds`
from ((`room_name` `rn` join `room_category`
`rct` on((`rn`.`room_category` = `rct`.`id`)))
left join `patient_detail` `pd` on(((`rn`.`id` = `pd`.`bed_type`)
and (isnull(`pd`.`discharge_date`) or (now() between `pd`.`admission_date` and `pd`.`discharge_date`)))))
where isnull(`pd`.`id`) group by `rn`.`room_category`