protected function getCatsAndSubCats($flag = FALSE) { $condition = ''; $categoryModel = new CategoryTableModel(); $categoryModel->setTable('category'); $categoryModel->readAllRecords(); $subCategoryModel = new SubCategoryTableModel(); $subCategoryModel->setTable('subcategory'); if (!$flag) { $condition .= "WHERE subcategory.category_id = " . end($categoryModel->getAllRecords())['id']; } $subCategoryModel->readAllRecords('*', $condition); return ['cats' => array_reverse($categoryModel->getAllRecords()), 'subcats' => array_reverse($subCategoryModel->getAllRecords())]; }
public function deleteCategoryAction($id = NULL) { header('Content-type: text/plain; charset=utf-8'); header('Cache-Control: no-store, no-cache'); header('Expires: ' . date('r')); $id = Validate::validateInputVar('catid', 'INPUT_GET', 'int'); $this->deleteSubCategoryAction('category_id', $id); $model = new CategoryTableModel(); $model->setTable('category'); $model->setId($id); if ($model->deleteRecord()) { $this->getCategoriesAction(); } }
public function newCatAction() { $fc = FrontController::getInstance(); $model = new CategoryTableModel(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $model->setTable('category'); if ($model->setData()) { $model->addRecord(); } } // header('Location: ' . $_SERVER['HTTP_REFERER']); // exit; }