From 482149780482e31bd685c8a3576587e74a19f3c3 Mon Sep 17 00:00:00 2001 From: Gilles Crettenand Date: Thu, 28 May 2015 10:20:41 +0200 Subject: [PATCH] new function to get Random Books --- mobile.netbiblio.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mobile.netbiblio.php b/mobile.netbiblio.php index fe2f61b..e59b86d 100644 --- a/mobile.netbiblio.php +++ b/mobile.netbiblio.php @@ -262,6 +262,14 @@ class NetBiblio extends WebService return $this->AddFiles($book); } + public function GetRandomBooks($number = 100) { + $sql = "SELECT TOP $number NoticeId FROM Notices ORDER BY NEWID();"; + $ids = Connection::execute($sql)->to_array(); + $ids = array_map(function($a) { return $a['NoticeId']; }, $ids); + $books = AudioBook::findBy('NoticeId', $ids, true); + return array_values(array_map(array($this, 'AddFiles'), $books)); + } + public function Search($query, $start, $limit) { $query = array(