public function InsertNewProject(Project $p = null) { if ($p == null || !$p instanceof Project) { return null; } $props = array("UserID," => $p->getUserID(), "ClientID," => $p->getClientID(), "Title," => $p->getTitle(), "Description," => $p->getDescription(), "TotalWorkHours," => $p->getTotalWorkHours(), "TotalEstimateHours," => $p->getTotalEstimateHours(), "DateCreated" => $p->getDateCreated()); foreach ($props as $k => $v) { if ($v != null) { if ($k == "DateCreated") { $_props[$k] = "'" . $v . "'"; } else { if (gettype($v) == "string") { $_props[$k] = "'" . $v . "', "; } else { $_props[$k] = "{$v}, "; } } } } $this->_dbAdapt->IStatement($this->dbTbl, $_props); $tmp = $this->_dbAdapt->getLnk(); $tmp->query($this->_dbAdapt->getQry()); unset($tmp); return true; }
public function SaveProjectEdits() { //$tmp = BasicAuthService::EntryPointCheck(); $tmpProject = new Project((int) $_REQUEST["ProjectId"], $_SESSION["User"]->getUID(), (int) $_REQUEST["ClientID"], $_REQUEST["Title"], $_REQUEST["Description"], (double) $_REQUEST["TotalWorkHours"], (double) $_REQUEST["TotalEstimateHours"], $_REQUEST["DateCreated"]); $GLOBALS["App"]["ServiceAdapter"] = $this->_projectServiceAdpt; $tmpSetup = array("EditProjectUserId" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getUserID()), "EditProjectClientId" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getClientID()), "EditProjectTitle" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getTitle()), "EditProjectDescription" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getDescription()), "EditProjectTotalWorkHours" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getTotalWorkHours()), "EditProjectTotalEstimateHours" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getTotalEstimateHours()), "EditProjectDateCreated" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getDateCreated())); $failures = array(); $GLOBALS["App"]["Error"] = ""; foreach ($tmpSetup as $updateMethod => $parameters) { $success = $this->_projectServiceAdpt->{$updateMethod}($parameters[0], $parameters[1]); if (!$success) { $stringd = "++ {$updateMethod} failed with parameters: {$parameters['0']} and {$parameters['1']} ++"; $GLOBALS["App"]["Error"] .= "++ {$stringd} ++"; $failures[] = $stringd; } } $this->PostEditCallBack(count($failures) == 0 ? null : $failures); }