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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:39:52+00:00 2026-05-11T10:39:52+00:00

Can someone please explain re-usable structures for me? I was working on making some

  • 0

Can someone please explain ‘re-usable structures’ for me? I was working on making some db objects in php, but was told I was using too much processing from the computer cause I made stuff to complicated with the below objects:

My DB objects:

$db = new Database; $db->db_connect();  $post_content = new DbSelect; $post_content->select('id', 'title', 'firstName', 'created', 'catName', 'tagName'); $post_content->from('content');    $post_content->join('inner'); $post_content->on('category','cat_id','id'); $post_content->where('id','1'); $post_content->order('created');  $db->db_close(); 

Normal PHP:

mysql_connect(); mysql_db_select();  $query = 'SELECT id, title, s_name, created, cat_name, tag_name                 FROM content                 JOIN INNER category, cat_id, id                 WHERE id=1                 ORDER created';  mysql_close(); 

So to reiterate my questions: 1. A quick explanation of re-usable structures? 2. why is the first method using objects ‘wrong’?

please note: I’ll be googling this as well as hoping for feedback I know there a ‘tools’ like Zend and other’s that have plenty of db objects built into them, but I’m trying a DIY approach

  • 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. 2026-05-11T10:39:53+00:00Added an answer on May 11, 2026 at 10:39 am

    I’m not sure where to start on this one. Object Oriented design is not a trivial subject, and there are many ways it can go wrong.

    Essentially, you want to try to make logical indepedent objects in your application such that you can swap them out for other modules with the same interface, or reuse them in future projects. In your database example, look at PEAR::MDB2. PEAR::MDB2 abstracts the database drivers away from your application so that you don’t need to worry about which specific database you’re using. Today, you might be using MySQL to run your site. Tomorrow, you might switch to Postgresql. Ideally, if you use a proper OO design, you shoudn’t need to change any of your code to make it work. You only need to swap out the database layer for another. (Pear::MDB2 makes this as simple as changing your db connect string)

    May I suggest reading Code Complete by Steve McConnell. There’s a whole chapter on Classes. While the examples are primarily C++, the concepts can be applied to any programming language, including PHP.

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

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Delphi doesn't support array literals like that, especially not ones… May 12, 2026 at 1:02 am
  • Editorial Team
    Editorial Team added an answer I've experienced this problem from time to time, and with… May 12, 2026 at 1:02 am
  • Editorial Team
    Editorial Team added an answer Use simple strtotime() to easy calculate the date of last… May 12, 2026 at 1:02 am

Related Questions

I am 90% sure I saw this answer on stackoverflow before, in fact I
Can someone please explain me what's the difference between Swing and AWT? Are there
Can someone please explain why int (0.4 * 10.0) is 4 yet int ((2.4
Can someone please explain why this program outputs 0x00000004? class AndAssignment { static void

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.