/** * @param JobModel $model * @see ControllerBase::update() */ public function update($model) { if ($model->validateForUpdate()) { try { $query = <<<SQL UPDATE job SET primaryContactId = ? , companyId = ? , applicationStatusId = ? , lastStatusChange = ? , urgency = ? , nextActionDue = ? , nextAction = ? , positionTitle = ? , location = ? , url = ? WHERE id = ? SQL; $id = $model->getId(); $primaryContactId = $model->getPrimaryContactId(); $companyId = $model->getCompanyId(); $applicationStatusId = $model->getApplicationStatusId(); $lastStatusChange = $model->getLastStatusChange(); $urgency = $model->getUrgency(); $nextActionDue = $model->getNextActionDue(); $nextAction = $model->getNextAction(); $positionTitle = $model->getPositionTitle(); $location = $model->getLocation(); $url = $model->getUrl(); $stmt = $this->_dbh->prepare($query); if (!$stmt) { throw new ControllerException('Prepared statement failed for ' . $query); } if (!$stmt->bind_param('iiisssssssi', $primaryContactId, $companyId, $applicationStatusId, $lastStatusChange, $urgency, $nextActionDue, $nextAction, $positionTitle, $location, $url, $id)) { throw new ControllerException('Binding parameters for prepared statement failed.'); } if (!$stmt->execute()) { throw new ControllerException('Failed to execute UPDATE statement. (' . $this->_dbh->error . ')'); } /** * @SuppressWarnings checkAliases */ if (!$stmt->close()) { throw new ControllerException('Something broke while trying to close the prepared statement.'); } return $id; } catch (Exception $e) { throw new ControllerException($e->getMessage()); } } else { throw new ControllerException("Invalid data."); } }