예제 #1
0
            $student->set_id($_POST['id']);
            $student = $this->studentrepository->update($student);
            header("location:index.php?page=student&action=success");
        }
    }
    public function delete()
    {
        $id = $_GET['id'];
        $this->studentrepository->delete($id);
        header("Location: index.php?page=student&action=delete");
    }
}
if (isset($_GET['m'])) {
    $method = $_GET['m'];
} else {
    $method = "index";
}
$studentcontroller = new StudentController();
switch ($method) {
    case 'add':
        $studentcontroller->add();
        break;
    case 'edit':
        $studentcontroller->edit();
        break;
    case 'delete':
        $studentcontroller->delete();
        break;
    default:
        $studentcontroller->index();
}
예제 #2
0
<?php

if (!$_POST['isAjax']) {
}
require_once './.env.php';
require_once './Model/StudentModel.php';
require_once './Controller/StudentController.php';
$controller = new StudentController();
if (isset($_POST['action']) && !empty($_POST['action'])) {
    switch ($_POST['action']) {
        case 'newStudent':
            echo $controller->create();
            break;
        case 'removeStudent':
            echo $controller->removeStudent($_POST['studentId']);
            break;
        case 'storeStudent':
            echo $controller->storeStudent($_POST['form']);
            break;
        default:
            die;
            //TODO return error for ajax
    }
} else {
    echo $controller->index();
}