$sql = 'SELECT ' . $subSectionSQLColsArray[$section][$subSection] . ' ' .
"FROM $subSection $subSection, $section $section " .
"WHERE ${subSection}." . $idNameArray[$section] . "_id = ${section}.id ";
$sql = $this->dbAP->addFilterCriteriaToSQL($sql, $subSectionSQLColsNameArray[$section][$subSection], '', 'hasSubSection') . $sortSQL;
This block of code is designing a totally dynamic MySQL query.
Consider this.
$section = "partners"
$subSection = "feedback"
Table "partners" and table "feedback" are logically joined together by a foreign key constraint "feedback.partner_id".
No problem right?
Now, consider this:
$section = "students"
$subSection = "agencies"
A student can select an agency, but there is no foreign key constraint (the previous DBA felt a foreign key constraint would make it impossible to build a FULLTEXT search upon, so they're not joined), so the above PHP statement will break MySQL because there is no means of doing a WHERE clause.
So what on earth do I do? I have to keep the PHP statement as relatively intact as possible as it is part of an inheritable class method which means it has to be, you guessed it, fully FULLY dynamic!
Thanx
Phil