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 6166407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:20:03+00:00 2026-05-23T22:20:03+00:00

trying to working with Zend_Db_Tables task is to retrive data from 2 or may

  • 0

trying to working with Zend_Db_Tables
task is to retrive data from 2 or may be 3 tables and return as json.

code:

public function getWorkerAction()
{
    $request = $this->getRequest();

    $workers = new table_1();
    if (!$worker) {
        $res = array(
            'success' => false,
            'data' => 'empty',
        );
    }
    else {
        $card = $worker->findParentRow('Table2');
        $res = array(
            'success' => true,
            'data' => array_merge($worker->toArray(), $card->toArray()),
        );
    }

    $this->_helper->json($res);
}

problem is:

  1. field count = 30 in each (need only 3-10)
  2. some fields is BLOB/CLOB

generate select for every table in every place seems bed solution for me. and in this case how shall i generate selects for findParentRow

  • 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. Editorial Team
    Editorial Team
    2026-05-23T22:20:03+00:00Added an answer on May 23, 2026 at 10:20 pm

    Sounds like you’re needing a way to specify which fields you want to select from the parent table without having to write a whole $select. That will require a custom row class. ZF provides an easy way to do this. In your dependent table classes, add a rowClass line like this:

    class Table2 extends Zend_Db_Table_Abstract {
        ...
        protected $_rowClass = 'CustomTableRow';
        ...
    }
    

    Then make your custom class like this, which overrides the findParentRow method to allow you to input a simple array of field names:

    class CustomTableRow extends Zend_Db_Table_Row {
    
        public function findParentRow($parentTable, $ruleKey = null, Zend_Db_Table_Select $select = null, array $fields = array()) {
            if ($fields) {
                if ($select) {
                    $select->columns($fields);
                } else {
                    if (is_string($parentTable)) {
                        $parentTable = $this->_getTableFromString($parentTable);
                    } else if (!$parentTable instanceof Zend_Db_Table_Abstract) {
                        throw new Exception("Parent table parameter can only be a string or an instance of Zend_Db_Table_Abstract");
                    }
    
                    $select = $parentTable->select()
                        ->from($parentTable, $fields);
                }
            }
            return parent::findParentRow($parentTable, $ruleKey, $select);
        }
    
    }
    

    It would be easier if Zend_Db_Table_Row_Abstract didn’t specify that the 3rd input has to be an instance of Zend_Db_Table_Select, because then we could automatically check whether that input is an array of column names instead of an instance to that class. So we add a 4th input of our own and put that logic inside the method. Now you can do something like this inside your controllers:

    $worker->findParentRow('Table2', null, null, array('field1', 'field2', ...));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on trying to generate a report from a couple of database tables.
I’m working on trying to port an ASP.NET app from Server 2003 (and IIS6)
i am new in programming under linux and trying to get working this code:
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I've been trying to get the Zend Jquery autocomplete function working, when i noticed
I am trying to get a dojo comboBox working in Zend, with the following
I am working through trying to learn to program in Python and am focused
I am trying to start working with Excel documents through the OpenXML SDK Spreadsheet
So I have been working and trying for a couple of hours. I am
I have a SOAP client in Ruby that I'm trying to get working with

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.