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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:55:59+00:00 2026-05-16T03:55:59+00:00

Currently, I have a database access class named DB , which uses PDO .

  • 0

Currently, I have a database access class named DB, which uses PDO. I Then have a handful of sub-classes for accessing each table:

  • Users
  • Images
  • Galleries
  • Text
  • Videos

This was nice when I first started my project, but now I’m not sure if it’s that great, as I have a method for each database query that I use within each of these classes. For example:

Images::insertNew($filename)
Images::getTotalInGallery($galleryId)
Images::getAllInGallery($galleryId, $fetchStyle)
Images::updateDescription($imageId, $description)
Images::updateGallery($imageId, $galleryId, $orderNum)
Images::getSingle($imageId)
Images::getFilename($imageId)
Images::getImageIdByFilename($filename)


Galleries::getNameById($galleryId)
Galleries::getAll()
Galleries::getMaxImages($galleryId)
Galleries::checkIfExists($galleryId)
Galleries::createNew($galleryName)
Galleries::getById($galleryId)
Galleries::delete($galleryId)

Well, you get the idea. I have been adding these methods as the need for them arises, and in development, I start by just using the DB class:

//Execute a query
DB::query($query);

//Get a single row
$row = DB::getSingleRow($query);

//Get multiple rows
$rows = DB::getMultipleRows($query);

So, I test queries with my DB class, then when they are working, I wrap them in a method of the class that is related to it (Image class for images table, Galleries class for galleries table, etc.).

I feel like this will keep growing and growing as I add new features later on (which may be OK, but I’m not certain). Can anybody critique my method and/or provide alternative solutions?

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-05-16T03:56:00+00:00Added an answer on May 16, 2026 at 3:56 am

    No, this actually sounds pretty good. You seem to have a solid abstraction layer between business logic and data access (This is called Data Mapper pattern).

    The only problem with this getting big is, that you might end up with methods that overlap. You should also try to maintain a standard naming convenction across both classes.

    In Images the method is Images::insertNew and in Galleries it is Galleries:createNew.

    Do you actually have models? Because what it looks like is that you have a lot of queries to assemble single values, but not whole objects.

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

Sidebar

Related Questions

Currently I have a database of Courses, and it has 6 columns: class Course(models.Model):
I currently have a MySQL database which I was hoping to use to store
I currently have this code which reads the first field in a database record
I have an (access) database table which contains data I would like to populate
Currently I have one application in which I am able to access .mdb or
I have a class within my web application that handles all my database access.
I am currently using PHP PDO to access my database. That is all working
Current I have a seperate maven module for my database access, all my DAO
Currently I have database with the following associations: One Client to Many Intakes One
Currently I have a database with the following relationships: One Client has multiple Entities

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.