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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:08:32+00:00 2026-06-07T04:08:32+00:00

I have a module with two models that extend Zend_Db_Table_Abstract: class Departments_Model_Subpages extends Zend_Db_Table_Abstract

  • 0

I have a module with two models that extend Zend_Db_Table_Abstract:

class Departments_Model_Subpages extends Zend_Db_Table_Abstract
{
    protected $_name = 'bktg_departments_subpages';
    protected $_primary = 'id';
}

class Departments_Model_Departments extends Zend_Db_Table_Abstract
{
    protected $_name = 'bktg_departments';
    protected $_primary = 'id';
}

Reading through the documentation, what I want to do is something like this (obviously, wrong):

$depTable = new Departments_Model_Departments();
$subTable = new Departments_Model_Subpages();

$depQuery = $depTable->select()->setIntegrityCheck(false)
->from($depTable, array('id', 'title'))
->join($subTable, array('COUNT(id) as `count`'))
->where('bktg_departments.id = bktg_departments_subpages.parent_id');

What am I missing? I just can’t wrap my head around Zend joins, and I’m thinking I’m going to end up writing straight sql.

Thank you for having a look.

Edit

Here’s what I’m working with now:

$depQuery = $depTable->select()->setIntegrityCheck(false)
->from($depTable, array('id', 'title'))
->joinLeft($subTable, 'bktg_departments.id = bktg_departments_subpages.parent_id',       array('COUNT(id) as count'))
->order('id DESC')
->group('id');

The sql that works for me:

SELECT bktg_departments.id, bktg_departments.title, count(bktg_departments_subpages.id) FROM bktg_departments left join bktg_departments_subpages on bktg_departments.id = bktg_departments_subpages.parent_id group by bktg_departments.id

And I am having issues reproducing that in Zend.

  • 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-07T04:08:32+00:00Added an answer on June 7, 2026 at 4:08 am

    As far as I can tell, passing an object into the table parameter doesn’t give you the expected results, and always generates an error. Even a method such as $table->getName() generates errors so I was forced to type out the name manually. I don’t know if I was expecting more out of the select object then it’s capable of or this is a bug in 1.11. Either way, I hope this helps someone with their frustrations.

    The following code works:

    $depQuery = $depTable->select()->setIntegrityCheck(false)
    ->from($depTable, array('id', 'title'))
    ->joinLeft('bktg_departments_subpages', 'bktg_departments.id = bktg_departments_subpages.parent_id', array('count' => 'COUNT(bktg_departments_subpages.id)'))
    ->group('bktg_departments.id')
    ->order('bktg_departments.id DESC');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a module similar to the following: module One class Two def
Ok so i have two models: 1: pv_array (photovoltaic array) 2: module (photovoltaic module)
I have two models: call them questions and answers: class FacetQuestion(models.Model): the_question = models.CharField(max_length=50)
I have two model classes in my models.py module in the default location. PythonFinal
I have a Maven multi-module project and I need two different parent POMs in
I have written a Python module, and I have two versions: a pure Python
In my code base I find that two modules have structures with the same
I have these two modules : package G1; sub new { my $class =
I have two different modules that need access to a single file (One will
I have module application. When I run it, the main window of that app

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.