$companyState = Tools::param('companyState'); $companyZip = Tools::param('companyZip'); $companyPhone = Tools::param('companyPhone'); $companyUrl = Tools::param('companyUrl'); $rowStyle = Tools::param('rowStyle'); $rowId = Tools::param('rowId'); $newCompanyModel = null; try { $companyModel = new CompanyModel(); $companyModel->setAgencyCompanyId($agencyCompanyId); $companyModel->setCompanyName($companyName); $companyModel->setCompanyAddress1($companyAddress1); $companyModel->setCompanyAddress2($companyAddress2); $companyModel->setCompanyCity($companyCity); $companyModel->setCompanyState($companyState); $companyModel->setCompanyZip($companyZip); $companyModel->setCompanyPhone($companyPhone); $companyModel->setCompanyUrl($companyUrl); $companyController = new CompanyController(); $companyId = $companyController->add($companyModel); if (!($companyId > 0)) { throw new ControllerException("Add failed."); } $newCompanyModel = $companyController->get($companyId); $companyRowView = new CompanyListView('html', null); $rows = $companyRowView->displayCompanyRow($newCompanyModel, 'list', $rowStyle); } catch (ControllerException $e) { $companyRowView = new CompanyListView('html', null); $companyModel->setId($rowId); $rows = $companyRowView->displayCompanyRow($companyModel, 'add', $rowStyle, 'Add Company record failed. ' . $e->getMessage()); $result = 'FAILED';
public function getSome($whereClause = '1 = 1') { $sql = <<<SQL SELECT id , agencyCompanyId , companyName , companyAddress1 , companyAddress2 , companyCity , companyState , companyZip , companyPhone , companyUrl , created , updated FROM company WHERE {$whereClause} ORDER BY companyName SQL; $stmt = $this->_dbh->prepare($sql); if (!$stmt) { throw new ControllerException('Failed to prepare SELECT statement. (' . $this->_dbh->error . ')'); } if (!$stmt->execute()) { throw new ControllerException('Failed to execute SELECT statement. (' . $this->_dbh->error . ')'); } if (!$stmt->bind_result($id, $agencyCompanyId, $companyName, $companyAddress1, $companyAddress2, $companyCity, $companyState, $companyZip, $companyPhone, $companyUrl, $created, $updated)) { throw new ControllerException('Failed to bind to result: (' . $this->_dbh->error . ')'); } $models = array(); while ($stmt->fetch()) { $model = new CompanyModel(); $model->setId($id); $model->setAgencyCompanyId($agencyCompanyId); $model->setCompanyName($companyName); $model->setCompanyAddress1($companyAddress1); $model->setCompanyAddress2($companyAddress2); $model->setCompanyCity($companyCity); $model->setCompanyState($companyState); $model->setCompanyZip($companyZip); $model->setCompanyPhone($companyPhone); $model->setCompanyUrl($companyUrl); $model->setCreated($created); $model->setUpdated($updated); $models[] = $model; } return $models; }