Well here it is, the class itself in mostly its entirety... I just can't figure this out, and I'm deeply sorry..
class ActionPerformer extends DBActionPerformer {
var $id;
function ActionPerformer($id = '') {
$this->id = $id;
}
function add_dept() { // VOID (OR NULL) METHOD
/*-----------------------------------------------------------------------------------------------------------------------
This method will add a new department to the department table, since "department" is not a
valid section it cannot be internally handled by "$this->save()" option inherited from
DBActionGenerator
-------------------------------------------------------------------------------------------------------------------------*/
global $_POST;
foreach ($_POST as $key => $val) if (!isset(${$key})) ${$key} = $val;
$this->connect(); // YOU INHERIT THIS METHOD FROM DBActionPerformer
$sql = "SELECT id FROM department WHERE unique_key = '$unique_key'";
$query =& new MySQLQuery($sql, $this->getDBConn());
print_r("Query 1: "); print_r($query); print_r("<P>");
$result =& $query->getResult();
print_r("Query 2: "); print_r($query); print_r("<P>");
if (@sizeof($result) > 0) { // DUPLICATE ENTRY FOUND - CLOSE DB CONNECTION AND EXIT METHOD
$result = null; $query = null;
$this->disconnect();
return null;
}
print_r("Query 3: "); print_r($query); print_r("<P>");
$result = null; $query = null;
print_r("Query 4: "); print_r($query); print_r("<P>");
if (is_array($department_parent_id) && @sizeof($department_parent_id) > 0) {
foreach ($department_parent_id as $key => $val) {
$sql = 'INSERT INTO department (' .
' department_name, department_parent_id, unique_key, record_entered ' .
') VALUES (' .
"'" . mysql_escape_string($department_name) . "', " .
"$key, " .
"'$unique_key', " .
"'" . date('Y-m-d H:i:s') . "'" .
')';
// HACK AS OF 2/18/2004: THIS SHOULD BE A CALL TO MySQLQuery CLASS INSTEAD.. I HAVE NO IDEA WHAT IS GOING ON! --Phil
$query =& new MySQLQuery($sql, $this->getDBConn());
print_r ("department_parent_id! "); print_r($query);
if (!mysql_query($sql, $this->getDBConn())) {
$this->setErrorArray(array($action => "Could not perform query: " . mysql_error()));
break;
}
}
} else {
print_r("Query 5: "); print_r($query); print_r("<P>");
$sql = 'INSERT INTO department (' .
' department_name, unique_key, record_entered ' .
') VALUES (' .
"'" . mysql_escape_string($department_name) . "', " .
"'$unique_key', " .
"'" . date('Y-m-d H:i:s') . "'" .
')';
// HACK AS OF 2/18/2004: THIS SHOULD BE A CALL TO MySQLQuery CLASS INSTEAD.. I HAVE NO IDEA WHAT IS GOING ON! --Phil
print_r("sql = "); print_r($sql); print_r("<P>"); print_r("this->getDBConn() = "); print_r($this->getDBConn()); print_r("<P>");
print_r("Query 6: "); print_r($query); print_r("<P>");
$query =& new MySQLQuery($sql, $this->getDBConn());
print_r("Query 7: "); print_r($query); print_r("<P>");
if (!mysql_query($sql, $this->getDBConn())) $this->setErrorArray(array($action => "Could not perform query: " . mysql_error()));
}
$this->disconnect();
print_r("Query 8: "); print_r($query); print_r("<P>");
}
}
Please refer to the earlier code for MySQLQuery and for the record DBActionPerformer extends MethodGeneratorForActionPerformer which has the method setErrorArray(), just so you know..
Phil