also use raw for wishes

master
Gilles Crettenand 11 years ago
parent a4713135f3
commit 71b2af844f

@ -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);
}
}
Loading…
Cancel
Save