Method GET All

This method used for display all data in your table in the form of JSON format

$app->get('/movies', function ($request,$response) {
    try{
        $con = getDB();
        $sql = "SELECT * FROM t_movie";
        foreach ($con->query($sql) as $data) {
            $result[] = array(
                'id_movie'      => $data['id_movie'],
                'movie_title'   => $data['movie_title'],
                'movie_rate'    => $data['movie_rate']
           );
        }
        if($result){
            return $response->withJson(array('status' => 'true','result'=>$result),200);
        }else{
            return $response->withJson(array('status' => 'Movies Not Found'),422);
        }


    }
    catch(\Exception $ex){
        return $response->withJson(array('error' => $ex->getMessage()),422);
    }

});

results matching ""

    No results matching ""