An example of an MVC controller

后端 未结 6 559
有刺的猬
有刺的猬 2020-12-22 16:09

I have been reading a lot about how and why to use an MVC approach in an application. I have seen and understand examples of a Model, I have seen and understand examples of

6条回答
  •  难免孤独
    2020-12-22 16:50

    Please check this:

        insert("employee", $_POST)){
                $data = array(
                    'success' => true,
                    'message' => 'Saving Successful!',
                );
            }
    
            echo json_encode($data);
        }
    
        if ($event == 'update') {
            if($conn->update("employee", $_POST, "id=" . $_POST['id'])){
                $data = array(
                    'success' => true,
                    'message' => 'Update Successful!',
                );
            }
    
            echo json_encode($data);
        }
    
        if ($event == 'delete') {
            if($conn->delete("employee", "id=" . $_POST['id'])){
                $data = array(
                    'success' => true,
                    'message' => 'Delete Successful!',
                );
            }
    
            echo json_encode($data);
        }
    
        if ($event == 'edit') {
            $data = $conn->get("select * from employee where id={$_POST['id']};")[0];
            echo json_encode($data);
        }
    ?>
    

提交回复
热议问题