Forums

problems with sub models array information

casals 19 Nov, 2016
Hi,

I have a problem in showing from sub models information that is in array..

I have 3 models (and tables); Reservation, ServiceCategorys and Services - where all the reservations are on it own main table (reservation_id, ect), the ServiceCategories (service_id, service_name) have the options that they can chose, and in the Services are the values for the services (id, reservation_id, service_id, service_value).

Services 'belongTo' (JOIN INNER) => ServiceCategories 'belongTo' (JOIN INNER) => Reservation

If i put on the 'Front list' PHP Functions;

Reservation.Services: $temp = \GCore\Libs\Arr::getVal($row, array("Services", "[n]", "request_id"), array()); return print_r($temp );

to show that is there i get;

Array ( 
  [id] => Array ( ) 
  [service_id] => Array ( ) 
  [reservation_id] => Array ( ) 
  [service_value] => Array ( ) 
) 


My head is not working today.. How i can print / show the values there..? Thanks.
How I can
GreyHead 19 Nov, 2016
1 Likes
Hi casals,

Can you try this to see what data is available:
Reservation.Services: return print_r($row );
Hopefully that will give you clues about a. if there is any data and b. what the structure is.

Bob
casals 23 Nov, 2016
Hi, Thank you for your prompt reply.

I still have some problems in reading / getting information from sub models, specially if there is more than one record matching the search (aka user = group). Its working fine in "belongsTo" relation.. but if i change the relation to "HasMany", then I get errors all the time (Even with new models for testing). No idea why. Is there any documentation on CC5 and "HasMany" relations?

The main problem its very simple; Like in User = Groups relations, i need to read and print the information about all the groups (names) to where the user belongs. But for some reason, this seems to be too hard..
GreyHead 23 Nov, 2016
Hi casals,

I am no expert on CC relationships :-(

What Errors do you get and what query do you see with the CC Debugger turned on. It should be possible form that + the debugger code in my last post to work out exactly want is happening.

Bob
This topic is locked and no more replies can be posted.