Can get informations about a specific user

This commit is contained in:
Pierre
2018-03-11 10:57:01 +01:00
parent cd81cfd8ba
commit 6cc90d281f
2 changed files with 35 additions and 2 deletions

View File

@ -28,15 +28,25 @@ class friends {
* Get and returns the list of the friends of a user
*
* @param int $userID The ID of the user
* @param int $friendID The ID of a specific friend (default -1)
* @return array The list of the friends of the user (Friend objects)
*/
public function getList(int $userID) : array {
public function getList(int $userID, int $friendID = -1) : array {
//Prepare the request on the database
$tableName = $this->friendsTable.", utilisateurs";
$condition = "WHERE ID_personne = ? AND amis.ID_amis = utilisateurs.ID ORDER BY utilisateurs.last_activity DESC";
$condition = "WHERE ID_personne = ? AND amis.ID_amis = utilisateurs.ID ";
$condValues = array($userID);
//Check if the request is targeting a specific friend
if($friendID != -1){
$condition .= " AND ID_amis = ?";
$condValues[] = $friendID;
}
//Complete conditions
$condition .= "ORDER BY utilisateurs.last_activity DESC";
//Specify which fields to get
$fieldsList = array(
"utilisateurs.last_activity",