private function getFindSql(FocSearchCriteria $search = null) { $sql = 'SELECT username, email FROM Users'; $orderBy = 'username, email'; if ($search !== null) { if ($search->getStatus() !== null) { $sql .= 'AND status = ' . $this->getDb()->quote($search->getStatus()); // switch ($search->getStatus()) { // case Users::STATUS_PENDING: // $orderBy = 'username, email'; // break; // case Users::STATUS_DONE: // case Users::STATUS_VOIDED: // $orderBy = 'username DESC, email'; // break; // default: // throw new Exception('No user for status: ' . $search->getStatus()); // } } } $sql .= ' ORDER BY ' . $orderBy; return $sql; }
<?php $status = Utils::getUrlParam('status'); FocValidator::validateStatus($status); $dao = new FocDao(); $search = new FocSearchCriteria(); $search->setStatus($status); // data for template $title = Utils::capitalize($status) . 'Foc'; $foc = $dao->find($search);
<?php $status = Utils::getUrlParam('status'); UsersValidator::validateStatus($status); $dao = new UsersDao(); $search = new FocSearchCriteria(); $search->setStatus($status); // data for template $title = Utils::capitalize($status) . 'Users'; $Users = $dao->find($search);