View Full Version : Info needed about associations (hasmany, belongs to...)

31 May 2013, 10:44 AM
I am trying to learn Extjs and in reading about models in the documentation, I came across the associations information. Would I use associations in the model to replace joins in my sql statements? Right now I am using joins in my php sql code to gather the fields I need from the different tables to display and after reading the docs, I am thinking I need to use the hasmany, hasone, belongsto... associations instead. Is that a fair statement? If so, then in each of my models, I need a proxy to just gather data from the one table.

Is there a simple example that uses php that shows how php gets the right matching record(s)?

3 Jun 2013, 11:03 AM
Any thoughts or insight to this?

3 Jun 2013, 12:58 PM
Don't know that I've seen any PHP examples for responding to a model's request for information. The best guide out there now is:

though it is to cover the concepts, really, more than practical implementation. Each associated model when loading would send up a request to the server with its configured proxy and would load its associated data which would call on your server to query the data for that load operation specifically - unless you're loading the main model and all of its associated data models all at once when loading a parent model using a larger, nested data response.

5 Jun 2013, 7:33 AM
My thought would be to provide a grid of items to the user, like all the company records we have (about 1200 records). Then the user would select a company for more details and I would query the server for that one company record with most of the child tables to be displayed into an edit form to be viewed. Just that Im kinda stuck, once a user selects a row in the grid that has the company primary key, how does that get back to the server to pull the detail and all child records. Am I needing to send it back to the server as json?