Need some advice about a sql class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Need some advice about a sql class

Post by dreamline »

Hi all,
I was just wondering if it's a good idea to create a class for all the queries my site uses.. Basically i want to store all the queries on my db in a class instead of running them from different pages. Incase something needs to be changed then a class is easier to maintain then all the different pages...

What do you think about it, should or shouldn't I store all possible queries in a class or is it better to fire off queries from individual pages?

Thanks for any comments on this... :D
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Need some advice about a sql class

Post by Chris Corbyn »

dreamline wrote:Hi all,
I was just wondering if it's a good idea to create a class for all the queries my site uses.. Basically i want to store all the queries on my db in a class instead of running them from different pages. Incase something needs to be changed then a class is easier to maintain then all the different pages...

What do you think about it, should or shouldn't I store all possible queries in a class or is it better to fire off queries from individual pages?

Thanks for any comments on this... :D
You hit the nail right on the head :)

It's far easier to maintain... and if you change the DB structure you don't have to edit all your pages, you just edit the class. Do it ;)
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

Thanks d11wtq for your quick answer.. :) I think, no i am sure, i will follow your advice and create an sql class.. :D
Post Reply