mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-30 09:16:35 +00:00
Can get the list of movies of the user
This commit is contained in:
parent
27a9d69370
commit
0363f3188f
26
RestControllers/moviesController.php
Normal file
26
RestControllers/moviesController.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* User personnal movies controller
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
class moviesController {
|
||||
|
||||
/**
|
||||
* Get the list of movies of the user
|
||||
*
|
||||
* @url POST /movies/get_list
|
||||
*/
|
||||
public function get_movies_list(){
|
||||
|
||||
user_login_required(); //Need login
|
||||
|
||||
//Fetch the database
|
||||
$movies = CS::get()->components->movies->get_list(userID);
|
||||
|
||||
return $movies;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,27 @@ class Movies {
|
||||
*/
|
||||
const MOVIES_TABLE = "galerie_video";
|
||||
|
||||
/**
|
||||
* Get the entire list of movies of a user
|
||||
*
|
||||
* @param int $userID The ID of the user to get
|
||||
* @return array The list of movie of the user
|
||||
*/
|
||||
public function get_list(int $userID) : array {
|
||||
|
||||
//Perform a request on the database
|
||||
$conditions = "WHERE ID_user = ? ORDER BY ID DESC";
|
||||
$values = array($userID);
|
||||
|
||||
$results = CS::get()->db->select($this::MOVIES_TABLE, $conditions, $values);
|
||||
|
||||
$movies = array();
|
||||
foreach($results as $row)
|
||||
$movies[] = $this->parse_db_infos($row);
|
||||
|
||||
return $movies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get informations about a movie
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user