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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:20:36+00:00 2026-06-11T15:20:36+00:00

To be frank, I am quite new to object oriented programming. I’m more familiar

  • 0

To be frank, I am quite new to object oriented programming. I’m more familiar with procedural code such as C and so forth.

I started designing a website with php as its underlying framework. Originally, I stuck with a procedural style design. That became quite cumbersome rather quickly. Needless to say, I want to use an object oriented approach. I see many opportunities to do so.

One in particular is in terms of accessing a database – MySQL in this case.

Right now, I am deciding how I want to design a database class. Obviously, it will incorporate a connection through PHP’s PDO. But I am stuck on what to include in the class other than that. It can clearly contain other methods, but to what degree? For instance, should I also include functions for MySQL querying, inserts, deletions, etc? These are common functions I’ll need to call regularly, so shouldn’t I include them all within the same class? Otherwise, it seems almost pointless to use classes if I need to create four or more different ones?

Anyone with more experience, please help! Thanks!

  • 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-06-11T15:20:37+00:00Added an answer on June 11, 2026 at 3:20 pm

    I like the idea of writing your own simple wrapper class. If at some point in the future you will want to switch to a different db library then all you have to do is change the code in the wrapper class.

    Where I work we wrote a wrapper class for php mysql functions. We have production and testing server where main mysql server is located on production and also additional server with replication. Our wrapper figures out where to connect to pull the data – there are cases where it connects to replicant for selects only. Credentials to every database we may want to connect to is defined in the wrapper which simplifies usage. Class methods are to execute sql, fetch one or all rows and dump into array, escape data, return last id etc. There is also a method that appends comment to each SQL statement with some useful information (like the file where query was executed) to ease debugging.

    Example to get data into array:

    $db = MysqlWrapper('db_name');
    $data = $db->fetchAll($query);
    

    and later on in the same code we can issue update or insert using the same instance.

    $db->execute($query);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was programming the example code from Frank Luna's book Introduction to 3D Game
I have the following code: <ul id=meganFox> <li>Frank</li> <li>Jeff</li> <li>Bob</li> </ul> <div id=debug></div> <script
I have three collections var col1 = new {Name1 = Frank, ID1 = 123,
Here's what the text looks like: 428, http://www.youtube.com/watch?v=aqlJl1LfDP4, NEW YORK,NEW YORK- FRANK SINATRA -
So I have started learning directx11 using a book by Frank D.Luna. His examples
Code | FName | Freq --------------------- L1 | Ted | 4 L1 | Frank
I'm new to cucumber, but enjoying it. I'm currently writing some Frank tests, and
I have UserComments table like this : 1 | Frank | hello world 2
Let´s be frank, my knowledge regarding SQL language is very low. Nevertheless, my boss
table1 | id | value -------------------- 1 | john 2 | frank 3 |

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.