Use the same method to get Genres / Types / Categories
This commit is contained in:
@@ -187,36 +187,16 @@ class AudioBook extends DbMapping
|
||||
}, $results->to_array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the list of all genres
|
||||
*/
|
||||
public static function ListOfGenres()
|
||||
{
|
||||
$sql = "SELECT
|
||||
LTRIM(RTRIM(Code)) as code,
|
||||
TextFre AS text
|
||||
FROM Codes
|
||||
WHERE
|
||||
type=2
|
||||
AND Code!='-'
|
||||
ORDER BY TextFre;";
|
||||
|
||||
$results = Connection::execute($sql);
|
||||
return array_map(function($row) {
|
||||
return array(
|
||||
'code' => $row['code'],
|
||||
'text' => $row['text'],
|
||||
);
|
||||
}, $results->to_array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the list of all type available in the database.
|
||||
* @param boolean $withJeunesse add 'Jeunesse' to the list
|
||||
* @return array
|
||||
*/
|
||||
public static function listOfTypes()
|
||||
public static function ListOfGenres($withJeunesse = false)
|
||||
{
|
||||
$sql = "SELECT DISTINCT
|
||||
Codes.TextFre AS type
|
||||
LTRIM(RTRIM(Codes.Code)) as code,
|
||||
LTRIM(RTRIM(Codes.TextFre)) AS text
|
||||
FROM Codes
|
||||
INNER JOIN Notices ON Codes.Code = Notices.MediaType2Code
|
||||
WHERE
|
||||
@@ -226,11 +206,11 @@ class AudioBook extends DbMapping
|
||||
AND Notices.NoticeNr NOT LIKE '%T%'
|
||||
AND Notices.MediaType1Code = 'CDD';";
|
||||
|
||||
$results = Connection::execute($sql);
|
||||
$results = array_map(function($r) {
|
||||
return $r['type'];
|
||||
}, $results->to_array());
|
||||
array_unshift($results, "Jeunesse");
|
||||
$results = Connection::execute($sql)->to_array();
|
||||
|
||||
if($withJeunesse) {
|
||||
array_unshift($results, array('code' => 'J', 'text' => 'Jeunesse'));
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user