Zend_Db_Table_Abstract Joining tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bilibytes
    New Member
    • Jun 2008
    • 128

    Zend_Db_Table_Abstract Joining tables

    Hi there,

    I am wondering if there is a possibility to declare a Model_DbTable_T able1JoinedToTa ble2ToTable3... class

    It would be convenient to create compound table from several tables joined from a foreign key.

    Lets say we have:

    tables:
    Code:
    -------------------------------------------
    users
    ------------------------------------------
    id | name | password | email
    ,
    Code:
    -----------------------------------------
    users_info
    -----------------------------------------
    id | user_id | location_id | description | age | ...
    ,
    Code:
    -------------------------------------------
    locations
    ------------------------------------------
    id | name | country_id
    and
    Code:
    -------------------------------------------
    countries
    ------------------------------------------
    id | name
    where:
    -users_info.user _id would be a foreign key to users.id
    -users_info.loca tion_id would be a foreign key to locations.id
    -location.countr y_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_U sers
    2. Model_DbTable_U sersInfo
    3. Model_DbTable_L ocations
    4. Model_DbTable_C ountries

    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_V irtual_UsersPro fileInfo

    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
Working...