From 71b2af844fb0a7da78ab7bb7a2a49f5e092699fa Mon Sep 17 00:00:00 2001 From: Gilles Crettenand Date: Wed, 20 May 2015 15:51:00 +0200 Subject: [PATCH] also use raw for wishes --- lib/User.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/User.php b/lib/User.php index cba2969..6b1c050 100644 --- a/lib/User.php +++ b/lib/User.php @@ -225,14 +225,18 @@ class User extends DbMapping public function getWishes($limit = 50) { if (!$this->wishes) { - $strSQL = "SELECT TOP " . $limit . AudioBook::$idColumn . " FROM " . User::$wishTableName . " WHERE " . User::$idColumn . " = $this->id ORDER BY CreationDate desc"; + $sql = "SELECT TOP $limit + NoticeID + FROM ".User::$wishTableName." + WHERE ".User::$idColumn . " = $this->id + ORDER BY CreationDate desc"; - $result = Connection::execute($strSQL); + $result = Connection::execute($sql); $ids = array(); while ($row = $result->next()) { $ids[] = $row['NoticeID']; } - $this->wishes = AudioBook::find($ids); + $this->wishes = AudioBook::findBy('NoticeID', $ids, true); } return $this->wishes; } @@ -246,7 +250,7 @@ class User extends DbMapping $noticeId = str_replace("'", "''", $noticeId); $table = User::$wishTableName; $strSQL = "DELETE FROM $table"; - $strSQL .= " WHERE " . AudioBook::$idColumn . " = $noticeId AND " . User::$idColumn . " = $this->id;"; + $strSQL .= " WHERE NoticeID = $noticeId AND " . User::$idColumn . " = $this->id;"; Connection::execute($strSQL, true); } } \ No newline at end of file