Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 74579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:22:49+00:00 2026-05-10T20:22:49+00:00

The situation is as follows: I’ve got 2 models: ‘Action’ and ‘User’. These models

  • 0

The situation is as follows: I’ve got 2 models: ‘Action’ and ‘User’. These models refer to the tables ‘actions’ and ‘users’, respectively.

My action table contains a column user_id. At this moment, I need an overview of all actions, and the users to which they are assigned to. When i use $action->fetchAll(), I only have the user ID, so I want to be able to join the data from the user model, preferably without making a call to findDependentRowset().

I thought about creating custom fetchAll(), fetchRow() and find() methods in my model, but this would break default behaviour.

What is the best way to solve this issue? Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:22:50+00:00Added an answer on May 10, 2026 at 8:22 pm

    I designed and implemented the table-relationships feature in Zend Framework.

    My first comment is that you wouldn’t use findDependentRowset() anyway — you’d use findParentRow() if the Action has a foreign key reference to User.

    $actionTable = new Action(); $actionRowset = $actionTable->fetchAll(); foreach ($actionRowset as $actionRow) {   $userRow = $actionRow->findParentRow('User'); } 

    Edit: In the loop, you now have an $actionRow and a $userRow object. You can write changes back to the database through either object by changing object fields and calling save() on the object.

    You can also use the Zend_Db_Table_Select class (which was implemented after I left the project) to retrieve a Rowset based on a join between Action and User.

    $actionTable = new Action(); $actionQuery = $actionTable->select()   ->setIntegrityCheck(false) // allows joins   ->from($actionTable)   ->join('user', 'user.id = action.user_id'); $joinedRowset = $actionTable->fetchAll($actionQuery); foreach ($joinedRowset as $joinedRow) {   print_r($joinedRow->toArray()); } 

    Note that such a Rowset based on a join query is read-only. You cannot set field values in the Row objects and call save() to post changes back to the database.

    Edit: There is no way to make an arbitrary joined result set writable. Consider a simple example based on the joined result set above:

    action_id  action_type  user_id  user_name    1          Buy          1       Bill    2          Sell         1       Bill    3          Buy          2       Aron    4          Sell         2       Aron 

    Next for the row with action_id=1, I change one of the fields that came from the User object:

    $joinedRow->user_name = 'William'; $joinedRow->save(); 

    Questions: when I view the next row with action_id=2, should I see ‘Bill’ or ‘William’? If ‘William’, does this mean that saving row 1 has to automatically update ‘Bill’ to ‘William’ in all other rows in this result set? Or does it mean that save() automatically re-runs the SQL query to get a refreshed result set from the database? What if the query is time-consuming?

    Also consider the object-oriented design. Each Row is a separate object. Is it appropriate that calling save() on one object has the side effect of changing values in a separate object (even if they are part of the same collection of objects)? That seems like a form of Content Coupling to me.

    The example above is a relatively simple query, but much more complex queries are also permitted. Zend_Db cannot analyze queries with the intention to tell writable results from read-only results. That’s also why MySQL views are not updateable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Right click on the title panel, in the Toolbox, where… May 11, 2026 at 1:31 pm
  • added an answer You should register it in all postbacks. Checking to see… May 11, 2026 at 1:31 pm
  • added an answer I found this solution, which is what I'm using now.… May 11, 2026 at 1:31 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.