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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:06:53+00:00 2026-05-12T12:06:53+00:00

I’m starting to work with oop to build a site of user generated data.

  • 0

I’m starting to work with oop to build a site of user generated data.

There are different types of data coming from my classes.
I have functions that get a list of data from the database, and functions to just select one item from those lists.
For example

function Get_Article($aid); //Gets an article
function Get_Users_Articles($uid); //Gets a multidemsional array of the users 
                                   //articles
function Get_Latest_Articles(); //Self explanatory by now
function Get_Local_Articles($zip); //Gets articles written by local users
function Get_Local_Users($zip); //Gets all local users

function Get_All_Article_Comments($aid); //Gets a multidimensional array of the 
                                     //comments written for an article
function Get_Article_Comment($cid); //Gets a single article comment

Now, how should I set up my classes to organize these functions.
Should I just put them all in the same class, or should I seperate the comments from the articles, or maybe seperate the functions that retrieve a single article/comment from those that retrieve a list of articles/comments. I might add more things to the site later that allow for comments, so I was thinking of just seperating all the comment functions from the others. Also, the “local” functions all use the same function that performs the math, so should I group those together, or maybe just use inheritance… any suggestion???

While on the subject of oop, I have a user class that looks like…
private $user = array();

public function Get_User_Data($uid){
  //get user data from database
  return $this->user;
}

public function Set_User_Data($user_array){
  $this->user = $user_array;
}

public function Add_User(){
  //INSERT data from $this->user into the database 
}

Now does anybody see anything wrong with the way this looks, mostly, should I set the user_data as a parameter for the Add_User function, instead of inserting the member variables?

  • 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-12T12:06:53+00:00Added an answer on May 12, 2026 at 12:06 pm

    First of all you need to understand that taking your old procedural style functions and wrapping them inside of objects doesn’t make your code object-oriented, it just means that you’re writing more complicated and horribly ugly procedural code.

    Secondly I would strongly recommend, in fact I cannot be too strenuous in my recommendations that you take some time to at least study the various PHP Frameworks that are out there. While you may never use any of them, I feel pretty safe in guaranteeing that studying any of them will give you a better grasp on object-oriented principles and good application design in general. In case you’ve never seen any before, the following should give a place to start:

    • Zend Framework
    • Symfony
    • CakePHP
    • Solar Framework

    Additionally, if you’ve never heard of Martin Fowler or Patterns of Enterprise Application Architecture, I would strongly recommend that you try and pick up a copy. He literally wrote the book that has provided the basic patterns that are in use in EVERY popular web framework.

    So much for my ‘read the manual response’ 😛

    In your particular case I would start with a basic Active Record pattern to contain your database access logic and your domain logic. In this type of pattern, each database table (users, articles, comments) is represented by a discrete object. The basic Active Record class for Users would contain all of the functions to get a specific user or a list of users as well as the functions to insert, update, or delete a user. In addition, a User Active Record class would contain methods to load a user’s articles and comments.

    A shell User class might look something like this:

    class User extends Active_Record {
    
    public function find() {}
    
    /**
        Single function performs inserts and updates for the object
    **/
    public function save() {}
    
    public function delete() {}
    
    public function getArticles() {}
    
    public function getComments() {}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.