I am wondering if there is a possibility to declare a Model_DbTable_Table1JoinedToTable2ToTable3... class
It would be convenient to create compound table from several tables joined from a foreign key.
Lets say we have:
tables:
Expand|Select|Wrap|Line Numbers
- -------------------------------------------
- users
- ------------------------------------------
- id | name | password | email
Expand|Select|Wrap|Line Numbers
- -----------------------------------------
- users_info
- -----------------------------------------
- id | user_id | location_id | description | age | ...
Expand|Select|Wrap|Line Numbers
- -------------------------------------------
- locations
- ------------------------------------------
- id | name | country_id
Expand|Select|Wrap|Line Numbers
- -------------------------------------------
- countries
- ------------------------------------------
- id | name
-users_info.user_id would be a foreign key to users.id
-users_info.location_id would be a foreign key to locations.id
-location.country_id would be a foreign key to countries.id
sometimes it would be convenient to just query the users table because it is lighter than all joined (i.e. Login) and in other cases it would be great to have all joined (i.e view user profile)
Zend Framework tells to declare a DbTable class for each table in the database, so there would be:
1. Model_DbTable_Users
2. Model_DbTable_UsersInfo
3. Model_DbTable_Locations
4. Model_DbTable_Countries
and i would like to add a 5th that would join all these tables together, and then be able to query the master table:
5 Model_DbTable_Virtual_UsersProfileInfo
the table would not phisically exist but would be dynamically created by modifying the query which would be a join + the query
now the big questions:
Is there a way to perform this in the Zend Framework
Is this a good approach of the problem?
Is there a better way?
thank you very much,
cheers!
bilibytes