<?php require_once "Libs/autoload.php"; $auth = new Auth(); if (!$auth->isAuthorized()) { $auth->forbidden(); exit(0); // Should never get here but just in case... } $id = Tools::post('id'); $result = 'OK'; $row = ""; try { $applicationStatusModel = new ApplicationStatusModel(); $applicationStatusModel->setId($id); $applicationStatusController = new ApplicationStatusController(); $applicationStatusController->delete($applicationStatusModel); } catch (ControllerException $e) { $result = "Delete failed. " . $e->getMessage(); } echo json_encode(array('result' => $result, 'row' => $row)) . PHP_EOL;
public function getSome($whereClause = '1 = 1') { $sql = <<<SQL SELECT id , statusValue , isActive , sortKey , style , created , updated FROM applicationStatus WHERE {$whereClause} ORDER BY sortKey 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 . ')'); } $stmt->bind_result($id, $statusValue, $isActive, $sortKey, $style, $created, $updated); $models = array(); while ($stmt->fetch()) { $model = new ApplicationStatusModel(); $model->setId($id); $model->setStatusValue($statusValue); $model->setIsActive($isActive); $model->setSortKey($sortKey); $model->setStyle($style); $model->setCreated($created); $model->setUpdated($updated); $models[] = $model; } return $models; }