So a side project of mine has involved the building of a pure PHP web app to generate a presentation. First off there is no way this is the easiest way to generate a presentation but this is the project as I was placed into it. My problem stems from solving a simple problem with a complex solution. Below is an example of a function that builds a SELECT query. The function takes 7 parameters and does not execute a query.

//This functions takes 6 arguments.
//1     ::      A string containing the table name
//2     ::      An array of strings containing the field to select
//3*    ::      An array of strings containing the column fields names comprising the WHERE statement
//4*    ::      An array of strings containing the respective field values comprising the WHERE statement
//5     ::      An array of special options to determine how the query is run. [Ex: MULTIQUERY, PREFERREDONLY]
//6     ::      The mode [Ex: 0 = Normal, 1 = Debug]
//7     ::      The number of rows to keep when using multiquery.
//*Note: These values should be in order from most importantant to least important
//*Example: $dbGivenFields[0] = "Interest" $dbGivenFields[1] = "Gender" because the interest is more important
// than the gender.  AgeRange and then Race would typically come next.
function querySelect($dbTable = NULL, $dbReturnFields = NULL, $dbGivenFields = NULL, $dbGivenValues = NULL, $dbOptions = NULL, $dbMode = 0, $dbKeepRows = 1)
        $functionName = "querySelect";
        $dbQuery = "Query Construction Failed.";
        $dbResult = FALSE;
        $bResults = FALSE; //false if no results are found
        $bMultiQuery = FALSE; //boolean that a query with new criteria should be sent if no results are found
        $bPreferred = FALSE; //indicates
        $dbMessage = "";
        //Test if the given values were NULL
        if($dbTable == NULL || $dbReturnFields == NULL || $dbGivenFields == NULL || $dbGivenValues == NULL)
                $dbMessage = "Query Construction Failed: Missing or NULL Argument";
                queryLog($functionName, $dbMessage, $dbQuery);
                return FALSE;
        //Test $dbOptions
        for($i = 0; $i < count($dbOptions); $i++)
                        case "MULTIQUERY":
                                $bMultiQuery = TRUE;
                        case "PREFERREDONLY":
                                $bPreferred = TRUE;
                        case NULL:
                                $dbMessage = "Invalid Parameter: \$dbOptions";
                                queryLog($functionName, $dbMessage, $dbQuery);
        $dbReturnFieldsCount = count($dbReturnFields); //count the number of desired fields
        $dbGivenFieldsCount = count($dbGivenFields); //count the number of columns
        $dbGivenValuesCount = count($dbGivenValues); //count the number of values

What this mess does is execute once or multiple times. Just think about the amount of time spent to handle the building of this simple query. This really doesn't even execute the query. That is handled in another file for reasons I cannot figure. While this may seem juvenalian but I cannot abide the amount of work this has added to the project. I was so surprised to see that this function logs the queries although it would be better if it reported the query after it attempted to execute it.

This is just a small piece of my headache.