Can get the list of movies of the user

This commit is contained in:
Pierre 2018-01-05 15:12:42 +01:00
parent 27a9d69370
commit 0363f3188f
2 changed files with 47 additions and 0 deletions

View 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;
}
}

View File

@ -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
*