php - Database access abstraction classes -


itemprop = "text">

Currently, I use a database class that uses DB named < Code> PDO . I have some sub-categories to reach each table:

  • User
  • Images
  • Gallery
  • Text
  • Video

It was good when I first started my project, but now I am not sure that it is very good because I have a method for every database query that I use each of these classes. For example:

  Image :: insertNew ($ file name) Images :: getTotalInGallery ($ galleryId) Images :: getAllInGallery ($ galleryId, $ fetchStyle) Images :: updateDescription ($ imageId) ($ ImageId) Images :: getFilename ($ imageId) Images :: getImageIdByFilename ($ file name) Gallery :: getNameById ($ GalleryId) Gallery :: getAll (Gallery) :: getMaxImages ($ galleryId) Gallery :: checkIfExists ($ galleryId) Gallery :: createNew ($ galleryName) Gallery :: getById ($ galleryId) Gallery :: Delete ($ galleryId)  

OK, you get the idea. I have been using these methods as the need for them, and in development, I just started using by db class:

  // one Execute Question DB:: Query ($ query); // Get a single row $ row = DB :: getSingleRow ($ query); // Get multiple rows $ rows = db :: MillMultiLio ($ query);  

Therefore, I ask questions with my DB class, when they are working, then I wrap them in a method of those sections which are related to it (picture table For Image Category, Gallery Category Gallery Table, etc.).

I think that it keeps growing and growing because I later add new features (which can be fine but I'm not sure). Can someone criticize my method and / or provide alternative solutions?

Thank you!

No, it really feels great You have business logic and data access (it's called ) Appears to be a solid intangible layer.

The problem with this problem is bigger, that you can end up with the methods that overlap, you should also try to maintain a standard naming convention in both classes

There are method images in the picture :: insertNew and the gallery has this gallery: .. CreateNew

Do you really have the model? Because it looks like you have too many queries to collect a single value, but not the whole object.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -