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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:46:27+00:00 2026-05-17T20:46:27+00:00

Hello I need help with displaying data from 2 table. So i Have 2

  • 0

Hello I need help with displaying data from 2 table.

So i Have 2 models:

//Klasy.php

class Model_Klasy extends Zend_Db_Table_Abstract
{
    protected $_name = 'klasy';
    protected $_primary = 'id';
    protected $_referenceMap = array(
    'Nauczyciele' => array(
        'columns'       =>  array('Wychowawca'),
        'refTableClass' =>  'Model_Nauczyciele',
        'refColumns'    =>  array('id')
    )
    );

    public function listaKlas()
    {
    $dane = $this->select();
    return $this->fetchAll();
    }
}

and

//Nauczyciele.php
    class Model_Nauczyciele extends Zend_Db_Table_Abstract
    {
        protected $_name = 'nauczyciele';
        protected $_dependentTables = 'Model_Klasy';
    }

In Controller have that code:

public function listaAction()
    {
        $modelLista = new Model_Klasy();
    $this->view->listaKlas = $modelLista->listaKlas();
    }

and in View this:

<b>Lista Klas:</b>
<table>
    <tr>
    <th>Klasa</th>
    <th>Rok rozpoczęcia nauki</th>
    <th>Wychowawca</th>
    </tr>
    <tr><?php echo $this->partialLoop('partials/ListaKlas.phtml', $this->listaKlas); ?></tr>
</table>

and partial file ListaKlas.phtml:

<tr>
    <td><?php echo $this->nazwa; ?></td>
    <td><?php echo $this->rok_rozpoczecia; ?></td>
    <td>
    <?php
    echo $this->Wychowawca;
    ?>
    </td>
    <td style="width: 5%">
    <a href="<?php echo $this->baseUrl() . '/klasy/edytuj/id/';
            echo $this->id ;?>">Edytuj
    </a>
    </td>
    <td style="width: 5%">
    <a href="<?php echo $this->baseUrl() . '/klasy/usun/id/';
            echo $this->id ;?>">Usuń
    </a>
    </td>
</tr>

from Table Nauczyciele i want display 2 columns but dont know how. I know about method findParentRow but dont know where use it and how render data from second table. In my case i see only ID from table Klasy.

  • 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-17T20:46:27+00:00Added an answer on May 17, 2026 at 8:46 pm

    You should have a detailed look at the way domain objects and database tables are mapped in the Zend Framework. For example, look at the quickstart: http://framework.zend.com/manual/en/learning.quickstart.create-model.html

    There is a model (Model_Klasy in your case), a mapper connecting models to DbTables (Model_KlasyMapper) and a class representing your Db table (Model_Klasy_DbTable_Klasy).

    In the domain layer the model is just the representation of your model without knowlegde of the database layer. The dbTable class knows how to connect to the databse and the mapper connects both classes to each other. The FetchAll() method should be inside the mapper, not the Model_Klasy itself.

    In the mapper, the fetchAll function might look like this:

    public function fetchAll()
    {
        $resultSet = $this->getDbTable()->fetchAll();
        $entries   = array();
        foreach ($resultSet as $row) {
            $entry = new Application_Model_Klasy();
            $entry->setId($row->id)
                  ->setName($row->name);
            $entries[] = $entry;
        }
        return $entries;
    }
    

    In this function you can use the $resultSet and $row to fetch additional information from related tables. The manual page Zend_Db_Table Relationships tells more about that: http://framework.zend.com/manual/en/zend.db.table.relationships.html

    The $row variable in the foreach loop of $resultSet is a Zend_Db_Table_Row and can find related information. Calling $row->findParentRow(‘Model_DbTable_Nauczyciele’) will fetch the relation.

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

Sidebar

Related Questions

Hello stack overflow I need help with this problem. Ok, I have a flat
Hello I need to retrieve data from database via an ajax call. I am
Hello I need help with Regular Expression, I want to match each section (number
Multi-Test TestNG.xml file results in java.lang.NullPointerException Hello Quality Team, I need help getting TestNG
Hello Fellow Computer People! Anyone willing to help will have my gratitude ;) Just
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello again ladies and gents! OK, following on from my other question on ASP.NET
Hello can anybody solve this please I'm creating the object in the action class
I need help while trying to spin articles. I want to find text and
I need help with a MySQL query. This example is much simpler than the

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.