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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:16:55+00:00 2026-05-12T20:16:55+00:00

I’m new to php and zend framework and fill very uncertain about following: For

  • 0

I’m new to php and zend framework and fill very uncertain about following:

For example, I have two tables:

table1: box(id, height, width, length, weight)
table2: labels(id, boxid, text, position)

labels.boxid -> box.id

(labels.boxid is a foreign_key for primary_key box.id)

I’ve generated two separate standard Zend_Db_Table_Abstract+Model+Mapper classes for both tables, which contains all set,get,fetchAll,fetchList methods.

The question: is it safe to extend Box Model to LabeledBox Model classes like this:

class NS_Model_LabeledBox extends NS_Model_Box {
     protected $_labels;

     public function setLabels($objs)
     {
        $this->_labels=$objs;
        return $this;
     }

     public function getLabels()
     {
        return $this->_labels;
     }

     public function getMapper()
     {
        if (null === $this->_mapper) {
            $this->setMapper(new NS_Model_LabeledBoxMapper());
        }
        return $this->_mapper;
     }

}

along with Mapper classes like this:

  class NS_Model_LabeledBoxMapper extends NS_Model_BoxMapper {
         public function fetchAll()
        {
            $resultSet = $this->getDbTable()->fetchAll();
            $entries   = array();

            foreach ($resultSet as $row) {
               $entry = new NS_Model_Box();
               ...setting box properties code...

               //fetching and setting labels for the box
               $labels = new NS_Model_Labels();

               $entry->setLabels(
                     $labels->fetchList("boxid='" . $row->id . "'") 
                     );
            }

            $entries[] = $entry;
        }
  }

so that I can finally run:

$labeledbox = new NS_Model_LabeledBox();
$entries  = $labeledbox->fetchAll();

foreach($entries as $entry)
{
   echo $entry->getId();
   echo $entry->getWeight();
       foreach($entry->getLabels() as $lables)
       {
          echo $lables->getText();
       }
}

This code ran fine for me.
I just don’t want to be left behind if there comes new release of ZF with any significant changes that can possible affect this “trick” (it still applies to OOP paradigm).

  • 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-12T20:16:56+00:00Added an answer on May 12, 2026 at 8:16 pm

    You do bring up a good point about hitting a moving target, and so far Zend Framework has been that. I started two different projects on ZF 1.7.x and have already re-written some classes due to changes in ZF. Of course, that was more of a desire to stay up-to-date with the “stable” release of ZF, so I didn’t really have to.

    Zend Framework is certainly a fast-moving framework, and that is something that you need to consider as you write your code, especially since there is talk of breaking backwards compatibility when 2.0.x is released.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.