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

  • Home
  • SEARCH
  • 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 7053735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:32:28+00:00 2026-05-28T03:32:28+00:00

If you have a complex SQL query involving many joins (for example returning Articles

  • 0

If you have a complex SQL query involving many joins (for example returning Articles with their associated many to many Tags) is there anything in Zend Framework that will produce the lovely CakePHP style database results:

Array
(
    [0] => Array
        (
            [ModelName] => Array
                (
                    [id] => 83
                    [field1] => value1
                    [field2] => value2
                    [field3] => value3
                )

            [AssociatedModelName] => Array
                (
                    [id] => 1
                    [field1] => value1
                    [field2] => value2
                    [field3] => value3
                )

        )
)

I don’t mind if it’s an object rather than an array, I just wondered if by using Zend_Db_Table to build a SELECT JOIN query I could save some leg work and get some nicely formatted results.

Here is the kind of code I’m using to build the query:

$select = $db->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
$select->from('tableName','fieldName')
     ->join('joinTable', 'joinTable.keyId = tableName.keyId',array())
     ->where('tableName.userId = ?', $userId);
$resultSet = $db->fetchAll($select);
  • 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-28T03:32:29+00:00Added an answer on May 28, 2026 at 3:32 am

    Nothing as pretty as what you’re used to just the data I asked for.
    The normal Result would be a rowset object, however the ->toArray() is available for most *Zend_DbTable_Abstract* methods.

    The $result->toArray() truncated and dumped using Zend_debug::dump():

    Lead Tracks array(7) {
      [0] => array(9) {
        ["trackid"] => string(2) "24"
        ["weekendid"] => string(1) "8"
        ["shiftid"] => string(1) "1"
        ["bidlocationid"] => string(1) "1"
        ["qty"] => string(1) "2"
        ["lead"] => string(1) "1"
        ["bidloc"] => string(14) "out of service"
        ["deptcode"] => string(3) "491"
        ["stationid"] => string(1) "1"
    }
    

    The query:

    where = $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
                         ->setIntegrityCheck(FALSE);
        $where->where('track.bidlocationid = ?', $bidlocationId)
              ->where('lead = ?', $lead)
              ->join('bidlocation', 'bidlocation.bidlocationid = track.bidlocationid')
              ->where('bidlocation.stationid = ?', $stationId)
              ->order('shiftid ASC')
              ->order('weekendid ASC');
    
        $result = $this->fetchAll($where);
    

    sorry, just utility 🙂

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

Sidebar

Related Questions

I have a Complex SQL Query which is written with lot many Joins and
I have a complex query that joins different tables to get the count. There
I have a complex SQL query that joins multiple tables. Here's a watered down
I have a complex LINQ to SQL to query, which joins onto two tables
I have a complex sql query that I have in a stored procedure and
I have a complex SQL Query, that needs to be filtered further. Part of
I have an sql query that counts the number of results for a complex
I have a very complex Linq to SQL query that returns a result set
I have a fairly complex query in SQL that performs a count across two
I have a somewhat complex SQL query that is pulling from a table of

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.