Where should I put a method that returns a list of active entries of a table?

Posted by darga33 on Programmers See other posts from Programmers or by darga33
Published on 2012-11-04T01:26:45Z Indexed on 2012/11/04 11:22 UTC
Read the original article Hit count: 196

Filed under:
|

I have a class named GuestbookEntry that maps to the properties that are in the database table named "guestbook". Very simple!

Originally, I had a static method named getActiveEntries() that retrieved an array of all GuestbookEntry objects. Each row in the guestbook table was an object that was added to that array. Then while learning how to properly design PHP classes, I learned some things:

  1. Static methods are not desirable.
  2. Separation of Concerns
  3. Single Responsibility Principle

If the GuestbookEntry class should only be responsible for managing single guestbook entries then where should this getActiveEntries() method most properly go?

Update:

I am looking for an answer that complies with the SOLID acronym principles and allows for test-ability. That's why I want to stay away from static calls/standard functions.

DAO, repository, ...? Please explain as though your explanation will be part of "Where to Locate FOR DUMMIES"... :-)

© Programmers or respective owner

Related posts about php

Related posts about object-oriented-design