Yours is a good example of why people go to the trouble of removing the absolute dependency on sql statements as far as possible from their scripts, much like people tend to try and use Templates to separate some of the hard core logic from display.
This is why you may find code similar to this elsewhere:
PHP Code:
<?php
include 'db.php';
$what = array('name','age'); //
$from = "PETS";
$where = "dob > '2005-12-31'; // string, but could be an array
$pets_starting_p = $db->select($what, $from, $where);
This is totally imaginary, but you can imagine you could tinker with $db and in that central place, set which database to use, which server and so on.
This basic premise can be taken to far greater degrees, take a look at ORM for example.
Anyhow, that huge rewrite may not be an option for you, but I mention it because you might bear it in mind for your next project. Think about centralising as much code as you can in an effort to apply the principles of DRY (Don't Repeat Yourself). If you do go that way I'd urge you to look at using PDP (or mysqli) and their prepared statements.
Many years back I used a multiple search/replace win32 tool whose name eludes me, but I thought it was called "ultimate search and replace", *nix tools abound for this kind of work. A lot may depend on whether you can say with absolute certainty that all of your SELECT statements are actually on one single line
Bookmarks