We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Table Data Binding Problems

In general speaking, if we have a table A's FK to a table B's PK, .NET have functions to auto binding a comboxing with DataGrid. say table A is a customer table and table B is a product table, customer is to purchase many products now. How can I show table A and with some columns in table B, as Phalcon's scaffold is just can one to one binding but no FK binding too.

Customer:
Name Mobile ProductID
John 444444 1001
Sally 444444 1001
Tim 444444 1002
Louis 445333 1003

Product:
ID Name
1001 Apple
1002 Orange
1003 Book

So I want to show in table that:
Name Mobile Product
John 444444 Apple
Sally 444444 Apple
Tim 444444 Orange
Louis 445333 Book

How can I do it?



2.2k

Check out https://docs.phalcon.io/en/latest/reference/models.html#relationships-between-models and https://docs.phalcon.io/en/latest/reference/models.html#virtual-foreign-keys and see where that gets you.

Seems like you can just update your models with the details of the table relationships, and you'll be good to go.