Remove all traces of AudioBook, clean up some warnings
This commit is contained in:
87
Lib/db/DbHelper.php
Normal file
87
Lib/db/DbHelper.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace BSR\Lib\db;
|
||||
|
||||
class DbHelper
|
||||
{
|
||||
/**
|
||||
* Retrieve the list of all readers (volunteers) having read at least 4 books (2 notices per book).
|
||||
* Returns an associative array containing $lastname and $firstname
|
||||
*/
|
||||
public static function ListOfReaders()
|
||||
{
|
||||
$sql = "SELECT
|
||||
count(*),
|
||||
ContentShortPart AS name
|
||||
FROM NoticeFields
|
||||
WHERE Tag=901
|
||||
GROUP BY ContentShortPart
|
||||
HAVING count(*) > 6
|
||||
ORDER BY SUBSTRING(ContentShortPart, CHARINDEX(' ', ContentShortPart)+1, 15);";
|
||||
|
||||
$results = Connection::execute($sql);
|
||||
return array_map(function($row) {
|
||||
$fullname = str_replace("*", "", $row['name']);
|
||||
$parts = explode(" ", $fullname);
|
||||
$firstname = array_shift($parts);
|
||||
$lastname = implode(" ", $parts);
|
||||
return array(
|
||||
'lastname' => $lastname,
|
||||
'firstname' => $firstname);
|
||||
}, $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 ListOfGenres($withJeunesse = false)
|
||||
{
|
||||
$sql = "SELECT DISTINCT
|
||||
LTRIM(RTRIM(Codes.Code)) as code,
|
||||
LTRIM(RTRIM(Codes.TextFre)) AS text
|
||||
FROM Codes
|
||||
INNER JOIN Notices ON Codes.Code = Notices.MediaType2Code
|
||||
WHERE
|
||||
Codes.Type = 2
|
||||
AND Notices.NoticeNr NOT LIKE '%~%'
|
||||
AND Notices.NoticeNr NOT LIKE '%V%'
|
||||
AND Notices.NoticeNr NOT LIKE '%T%'
|
||||
AND Notices.MediaType1Code = 'CDD';";
|
||||
|
||||
$results = Connection::execute($sql)->to_array();
|
||||
|
||||
if($withJeunesse) {
|
||||
array_unshift($results, array('code' => 'J', 'text' => 'Jeunesse'));
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the list of all books currently lent to readers.
|
||||
*/
|
||||
public static function InReading()
|
||||
{
|
||||
$sql = "SELECT
|
||||
NoticeNr, title, author, displayName
|
||||
FROM notices, items, circulations, UserAccounts
|
||||
WHERE
|
||||
MediaType1code='N' and NoticeNr not like '%~%'
|
||||
AND items.NoticeID = notices.NoticeID
|
||||
AND items.ItemID = circulations.ItemID
|
||||
AND UserAccounts.UserAccountID = circulations.UserAccountID
|
||||
ORDER BY author, title;";
|
||||
|
||||
$results = Connection::execute($sql);
|
||||
return array_map(function($row) {
|
||||
return array(
|
||||
"NoticeNr" => $row['NoticeNr'],
|
||||
"auteur" => $row['author'],
|
||||
"titre" => $row['title'],
|
||||
"lecteur" => $row['displayName']
|
||||
);
|
||||
}, $results->to_array());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user