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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:18:18+00:00 2026-05-18T08:18:18+00:00

I have to list several elements that are coming from a database source A

  • 0

I have to list several elements that are coming from a database source A and they are:
team_id, team_name and team_score (translated for explanation sake).

I need to loop over them, and display that information.

So, I have, on the DAO side:

public function listOfTeams()
{
  $select = $this->select()
    ->from(array('t'=>'teams'), array('cod_team','name','score'));
  return $this->fetchAll($select);

}

On my team controller:

public function listAction()
{
  $teamsDao = new TeamsDao();
  $this->view->infoTeam = $teamsDao->listOfTeams();                    
}

And at the view:

<?php for($i = 0; $i < 30; $i++): ?>

  <?php if(isset($this->infoTeam[$i])): ?>

Now, the thing is, on each of those listed items, I need to add more information.

That information doesn’t come directly from a database, but it’s a result of some calculations.

Take for example the percentage of games done. (translated);

$totalGamesNumber > 0 ? ($gamesDone*100)/$totalGamesNumber : 0);

So, I need to grab the total games number from the database, then, for each team, I need to have the number of games done, so that I can have the percentage to be displayed.

The $gamesDone are obtained by:

$gameTeamDao->countGamesPerTeam($gameVo, $teamVo);

I’m stuck here, because I cannot see where/how should I call and make the method for calculating the percentage, in order to allow the percentage of games completed to be presented along with the other data.

Can I have some help out of this mud ?

If you had to write a helper for this, more or less, how will it looked like?

Thanks in advance,
MEM

PS – If you need more detailed information. I can provide. I could be forgeting something that for me is taken, but that, for those who want to help it isn’t. So, just let me know. Thanks a lot again.

Update: translated all post to English for help sake.

  • 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-18T08:18:18+00:00Added an answer on May 18, 2026 at 8:18 am

    Since you are using ZF, you could make all this computations in the table row’s class. Here’s how. Let’s say your teams class is called Application_Model_DbTable_Teams.

    class Application_Model_DbTable_Teams extends Zend_Db_Table_Abstract
    {
        protected $_name = 'teams'; // table name
        protected $_id = 'teamId'; // table primary key
    
        // rows returned by fetchAll() will be of this class
        protected $_rowClass = 'Application_Model_DbRow_Teams';
    
    }
    

    Then you need to create the Application_Model_DbRow_Teams class where you will put the extra calculations

    class Application_Model_DbRow_Teams extends Zend_Db_Table_Row_Abstract
    {
        public $percentGamesDone;
    
        public function init()
        {
            // This method gets called automatically by ZF when you instantiate a new
            // object from this class
            // This is where you will put your extra calculations, 
            // like percentage games done, etc
            $this->percentGamesDone = $this->getPercentGames();
        }
    
        public function getPercentGames() 
        {
            $calculation = 3; // replace this with real data
            return $calculation;
        }
    }
    

    Once you’ve done this, you can simply use any of the row’s declared properties (like percentGameDone) directly from the view as they will be calculated right when you instanciate the rows.

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

Sidebar

Related Questions

I have an object in a list that I need to rank several different
I have several .list elements which all need a red color. Of these .list
I have an XML document that has several <item> elements. Inside each, there might
I have several lists of strings like so, from a possible list of several
I have a LinearLayout view that already contains several elements. I want to add
I have a program that handles several lists of elements (always with length >
I have a list on SharePoint with several hundred items in it. I also
I have a list of objects, IList<O> . O has several properties but only
I have several ReorderLists on a page. Each list has items added to it
I have several libraries made by myself (a geometry library, a linked list library,

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.