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

  • Home
  • SEARCH
  • 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 6810691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:14:11+00:00 2026-05-26T20:14:11+00:00

Currently, I build two classes for each database table. For instance, if I have

  • 0

Currently, I build two classes for each database table. For instance, if I have the table person, I will have the classes Person_List and Person.

Design-wise, is it better

  1. for Person_List to output an array of Person; or
  2. for it to output an array containing arrays of rows in the table.

Performance-wise, which is better?

  • 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-26T20:14:11+00:00Added an answer on May 26, 2026 at 8:14 pm

    I believe that design-wise, and taking performance into account, would be to (if you insist on Person_List class to represent table and Person to represent single record):

    • use Iterator interface for Person_List class, so you can iterate through the table without the need to pull all the records at once (it should be significant performance gain in some cases),
    • additionally use Countable interface for Person_List class, so you are able to count all the results if necessary by getting count directly from database,

    This should give you flexibility and allow you to use Person_List class objects similarly as arrays.

    If you still have problems employing these two interfaces, here is some explanation:

    • every time you do foreach ($table as $record) (where $table is an instance of Person_List), the current() method of Person_List class will be invoked (because it is a part of Iterator interface – see docs here), which should return an object of Person class; this should happen using eg. mysql_fetch_object();
    • when you call count($table) (where $table is an instance of Person_List), the count() method of Person_List class will be invoked, which in turn can use eg. mysql_num_rows() function to return all the results instead of pulling them from database and then counting (this will be again significant performance gain),
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'll try to explain as best I can: I have two classes I'm currently
Currently when I build my site I have to manually open validate it at
I'm currently experimenting with build script, and since I have an ASP.net Web Part
I am currently trying to build on TeamCity, which uses Microsoft.Office.Interop dll. This will
I have recently been put in charge of debugging two different programs which will
I have many build configurations in TeamCity, each servicing a large project. In the
I have a static library with two different targets: one to build for the
So I currently have a jQuery dialog with two buttons: Save and Close. I
I have a project where I need to build a two tables in sql
I have two questions re: visual studio 2008 and post-build events. 1) How do

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.