Managing SQL Queries in PHP
Posted 08 May 2006 - 07:30 PM
I was wondering what techniques people use to manage queries (i.e. include file for queries?) throughout their php code. I've just been writing them in on the pages I use and executing via ADODB, but it's making the code pretty ugly.
Thanks in advance.
Posted 08 May 2006 - 07:38 PM
However, if you're doing a ton of formatting or setup work to display the results of the query and you have several of those, that's when I start to split it out. I have several pages that are nothing but includes to different reports since I have one page that all my reports get printed from in one of my applications. Then I just include whatever report is called from the switch().
Quick question though... why use ADO? Unless you're using something like Access or MSSQL with field names > 30 characters, there's no reason not to use the built in libraries. ADO is really messy and not nearly as nice to deal with.
Info: PHP Manual
Posted 08 May 2006 - 08:04 PM
Regarding the ADODB question, I chose it partially for the easy session management and partially because the database might be changing in the future, and didn't want to have to re-code all of the query strings.
For include files, do you name them .inc, .inc.php, .php? I have basically modules for the system, and for "contacts" for instance, i have view/edit/update pages, which all share similar queries. I'd like to stick them all in one file, however, I don't want to be wasting memory setting all of the queries for each page, if they only use a few of them That's pretty much my problem.
Posted 08 May 2006 - 08:11 PM
Posted 08 May 2006 - 08:39 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users