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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:38:10+00:00 2026-05-30T12:38:10+00:00

Thanks in advance…see below the code.. i have 2 models, category and product my

  • 0

Thanks in advance…see below the code.. i have 2 models, category and product

my product model
class Admin_Model_Product extends Zend_Db_Table_Abstract {

protected $_name = 'products';
protected $_referenceMap = array(
    'category' => array(
        'columns' => array('category_id'),
        'refTableClass' => 'Admin_Model_Category',
        'refColumns' => array('id'),
        'onDelete' => self::CASCADE,
        'onUpdate' => self::RESTRICT
    )
);

}

my category model is:

class Admin_Model_Category extends Zend_Db_Table_Abstract {

protected $_name = 'categories';
protected $_dependentTables = array('Admin_Model_Product');

}
in my products controller i have

class Admin_ProductsController extends Zend_Controller_Action {

public function init() {

}

public function indexAction() {
    echo '<pre>';
    $model = new Admin_Model_Product();

}

}

What i need to do is get all the products using fetchAll() method and need to get parentrow of each product and display it in my view… i can pull all the products but i dont know how to find each products parent category and bind them, is there any example source code? or any suggestion ? i need an array containg all products and parent category name ..please be quick.thanks

  • 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-30T12:38:12+00:00Added an answer on May 30, 2026 at 12:38 pm

    try the following :

    retrieve categories and their products :

    $model_category = new Admin_Model_Category();
    $categorySet = $model_category->fetchAll(); 
    $categories = $categorySet->toArray();
    
    $i = 0;
    $results = array();
    foreach($categories as $category)
       $categoryRow = $model_category->fetchRow('id =', $category->category_id)
       $products = $categoryRow->findDependentRowset('Admin_Model_Product');
       $results[$i]['parent'] = $category;
       $results[$i]['products'] = $products;
       $i++;
    }
    

    then pass it to the view:

    $view->results = results;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks in advance.. In my WP7 application I have used following code for zooming
Thanks in advance for any help. I have the following code which when clicked
Thanks in advance. Getting this warning when using below code: Warning: file_get_contents(test.php) [function.file-get-contents]: failed
Thanks in advance for your help. I have a need within an application to
Thanks in advance for your assistance. I have the following exported part: [Export (typeof(INewComponent))]
Thanks in advance. This is my sample code. Whenever i try to run it
Thanks in advance for your time. I have a deeply nested XML whose XSLT
Thanks in Advance.... Can any one knows, I have a requirement to perfrom OnclickListener
Thanks in advance. I have Installed WAMP Server on System 4(192.168.1.104). I can Connect
Thanks in advance. What i currently have is a filedialog box selecting a text

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.