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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:06:45+00:00 2026-05-29T05:06:45+00:00

I have a tables named: client (id, alias) post (id, subject) post_client (id, post_id,

  • 0

I have a tables named:

client (id, alias)
post (id, subject)
post_client (id, post_id, client_id)

Many clients can be joined to a post.

Using Zend DB Table abstract I have started to build a model, here are the classes:

ORM_Post

class ORM_Post extends Zend_Db_Table_Abstract {

    protected $_name = 'Post';
    protected $_dependentTables = array('ORM_Post_Client');

}

ORM_Client

class ORM_Client extends Zend_Db_Table_Abstract {


    protected $_name = 'Client';
    protected $_dependentTables = array(
        'ORM_Post_Client'
    );
}

ORM_Post_Client

class ORM_Post_Client extends Zend_Db_Table_Abstract {

    protected $_name = 'Post_Client';
    protected $_referenceMap    = array(
        'post' => array(
            'columns'           => 'post_id',
            'refTableClass'     => 'ORM_Post',
            'refColumns'        => 'id'
        ),
        'client' => array(
            'columns'           => 'client_id',
            'refTableClass'     => 'ORM_Post_Client',
            'refColumns'        => 'id'
        )

    );
}

What I was hoping todo is call an instance of the Post and then load the clients associated aswell as loading an instance of the client and load all posts associated.

So I did this:

    $post = new ORM_Post();
    $results = $post->fetchAll();

    foreach ($results as $key => $result){
        $row = $results->current();
        $client = $row->findDependentRowset('ORM_Post_Client','client');
    }

and I get
Reference rule “client” does not reference table ORM_Post

I have battled with this for hours and cannot see where I’m going wrong. Am I to declare the Post_Client joins inside the client and post model also?

EDIT

Here is what I was after:

    $post = new ORM_Post();
$results = $post->fetchAll();
$return = array();

    foreach ($results as $result){
        $row = $post->find($result->id)->current();
        $return[$result->id] = $row->toArray();
        $return[$result->id]['clients'] = $row->findManyToManyRowset('ORM_Client', 'ORM_Post_Client')->toArray();
}

return $return;

Thanks for the advice guys, you put me on the right track

  • 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-29T05:06:46+00:00Added an answer on May 29, 2026 at 5:06 am

    in your ORM_Post_Client it should be

    'client' => array(
                'columns'           => 'client_id',
                'refTableClass'     => 'ORM_Client',  //instead of ORM_Post_Client 
                'refColumns'        => 'id'
            )
    

    refTableClass => The class name of the parent table. Use the class
    name, not the physical name of the SQL table (documentation)

    also i think your loop should be :

    foreach ($results as $result){
            $row = $results->current();
            $clients = $row->findDependentRowset('ORM_Post_Client','post'); 
      }
    

    because you are looking for clients of a post which means that post is your rule

    ($row->findDependentRowset($table, [$rule]); )

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

Sidebar

Related Questions

I have two tables: Client(id,name,...) Purchase(id,item,date,client_id,...) They have their respective Model, with their validations.
I have 3 tables: Client (fields: client_id, name) Permissions (fields: perm_id, title) Client_Permissions(fields: client_id,
Let's say you have a database with two tables named clients and referrals. TABLE
I have two tables/entities client and site that have a many to many relationship
I have two tables: services id client service and clients id name email How
I have 3 tables, Client, Tool and ClientTools. One client can have multiple tools,
I have those two tables: client: id (int) #PK name (varchar) client_category: id (int)
I have two tables named foo and bar , hypothetically speaking. foo has columns
Let's say you have three tables named Item, Event, and Seat, constructed as such:
I have two tables, both named as say, Employee in two different schema HR

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.