Forums

CCv5 reading data from related table

Giorgini 16 Nov, 2015
Good morning, I’m trying to use Chrono Connectivity V5 and I can’t display records of related tables.
I write a simple example similar to my configuration, Two database-tables:

TABLE “CUSTOMERS”
Customer_ID, Customer_Name, Customer_Address

TABLE “ORDERS”
Order_ID, Order_CustomerID, Order_Numer, Order_Date

In CCv5 I have a Connection with 2 models: “customers_model” (the main) and “orders_model”

In Orders_model, I set:
Table name: Orders
Relation: hasMany
Associated Model: Customers_models
Foreign key: Order_CustomerID

I can correctly see the list of all the customers, and when I click on one customer (by view linkable field) I correctly see the value of the fields of the Customers Table but I can’t see the value of the related table (orders).

I set the “Front List-> Actions-> view” like this:

<p>
{customers_model.Customer_Name} <br>
{customers_model.Customer_Address} <br>
{orders_model. Order_Numer}
</p>

P.S if I Change the Relation in “hasOne” I can see only the first record of the related table

What should I write instead of {orders_model. Order_Numer} to see all the records of the related table ?

Thanks, Fabio.
GreyHead 17 Nov, 2015
Hi Fabio,

Just checking - there should be no space in {orders_model.Order_Numer} - is that the problem?

Bob
Giorgini 17 Nov, 2015
Hi, there is no space.

i have N orders for each Customer and I would like to know whitch is the isctuction to get data from array
thanks, Fabio.
Giorgini 18 Nov, 2015
Answer
1 Likes
Hi,
I saw that I can get data from array like this: $this->data['orders_model'][$i]['Order_Numer']

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