Note that there are some explanatory texts on larger screens.

plurals
  1. PODatabase access abstraction classes
    primarykey
    data
    text
    <p>Currently, I have a database access class named <code>DB</code>, which uses <code>PDO</code>. I Then have a handful of sub-classes for accessing each table:</p> <ul> <li><code>Users</code></li> <li><code>Images</code></li> <li><code>Galleries</code></li> <li><code>Text</code></li> <li><code>Videos</code></li> </ul> <p>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:</p> <pre><code>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) </code></pre> <p>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 <code>DB</code> class:</p> <pre><code>//Execute a query DB::query($query); //Get a single row $row = DB::getSingleRow($query); //Get multiple rows $rows = DB::getMultipleRows($query); </code></pre> <p>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.).</p> <p>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? </p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload