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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:27:11+00:00 2026-06-07T06:27:11+00:00

I’ve got below function in my Organisation model. public function getOrganisations($where=null,$order=’name ASC’,$offset=null,$limit=null){ $Result =

  • 0

I’ve got below function in my Organisation model.

public function getOrganisations($where=null,$order='name ASC',$offset=null,$limit=null){
            $Result = $this->fetchAll($where,$order,$limit,$offset);
            if (!$Result){
                return array();
            }

            return $Result->toArray();
        }

but How can I include my organisation_types model so I can left join to organisation_type_id in organisation table?

  • 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-06-07T06:27:13+00:00Added an answer on June 7, 2026 at 6:27 am

    This is the core of the argument in favor of using the data mapper pattern.
    With the structure you seem to be using in your example you’ll have huge trouble trying pass the organisation_types object into your Organisation model. You can however do a join in your query to join to the organisation_types table, but joining on the object is not likely to be reasonable.

    to join on the organisation_types table:

    //assuming this is a DbTable model that extends Zend_Db_Table_Abstract
     function getOrganisations($where=null,$order='name ASC',$offset=null,$limit=null){
         $select = $this->select()->setIntegrityCheck(FALSE);//This locks the table to allow joins
         $select->joinLeft('organisation_types', 'organisation_types.id = organisation.organisation_type_id');//This will join the tables with all feilds, use the join type you like.
         if (!is_null($where) {
             $select->where($where);
         }
         if (!is_null($order) {
             $select->order($order);
         }
         if (!is_null($offset) {
             $select->limit(null,$offset);//offset is second arg in limit() in select()
         }
         if (!is_null($limit) {
             $select->limit($limit);
         }
           $Result = $this->fetchAll($select);
           if (!$Result){
                return array();
           }
    
           return $Result->toArray();
     }
    

    This should give you an idea of how a table join would work. If you want to use the objects you’ll need to begin again with a different structure.
    I found a couple of good tutorials on PHPMaster that helped me get my head around the data mappers and domain models.

    Building A Domain Model, Introduction
    Integrating data mappers

    Also The online book Survive The Deepend has a good example of the data mapper pattern and how to test it.

    Good Luck…

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
i got an object with contents of html markup in it, for example: string
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I have two tables with like below codes: Table: Accounts id | username |

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.