Get the list of readers from Solr
This commit is contained in:
@@ -4,33 +4,6 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user