convert mysql functions + direct query building -> sql standards + paramaters
This commit is contained in:
parent
ab9b4e9123
commit
c46f03bf8f
@ -110,10 +110,8 @@ class NumericScore implements Extension {
|
|||||||
//TODO: Somehow make popular_by_#/2012/12/31 > popular_by_#?day=31&month=12&year=2012 (So no problems with date formats)
|
//TODO: Somehow make popular_by_#/2012/12/31 > popular_by_#?day=31&month=12&year=2012 (So no problems with date formats)
|
||||||
//TODO: Add Popular_by_week.
|
//TODO: Add Popular_by_week.
|
||||||
|
|
||||||
$sql =
|
$sql = "SELECT * FROM images ";
|
||||||
"SELECT *
|
$args = array();
|
||||||
FROM images
|
|
||||||
";
|
|
||||||
|
|
||||||
//year
|
//year
|
||||||
if(int_escape($event->get_arg(0)) == 0){
|
if(int_escape($event->get_arg(0)) == 0){
|
||||||
@ -137,17 +135,17 @@ class NumericScore implements Extension {
|
|||||||
|
|
||||||
if($event->page_matches("popular_by_day")){
|
if($event->page_matches("popular_by_day")){
|
||||||
$sql .=
|
$sql .=
|
||||||
"WHERE YEAR(posted) =".$year."
|
"WHERE EXTRACT(YEAR FROM posted) = :year
|
||||||
AND MONTH(posted) =".$month."
|
AND EXTRACT(MONTH FROM posted) = :month
|
||||||
AND DAY(posted) =".$day."
|
AND EXTRACT(DAY FROM posted) = :day
|
||||||
AND NOT numeric_score=0
|
AND NOT numeric_score=0
|
||||||
";
|
";
|
||||||
$dte = array($totaldate, date("F jS, Y", (strtotime($totaldate))), "Y/m/d", "day");
|
$dte = array($totaldate, date("F jS, Y", (strtotime($totaldate))), "Y/m/d", "day");
|
||||||
}
|
}
|
||||||
if($event->page_matches("popular_by_month")){
|
if($event->page_matches("popular_by_month")){
|
||||||
$sql .=
|
$sql .=
|
||||||
"WHERE YEAR(posted) =".$year."
|
"WHERE EXTRACT(YEAR FROM posted) = :year
|
||||||
AND MONTH(posted) =".$month."
|
AND EXTRACT(MONTH FROM posted) = :month
|
||||||
AND NOT numeric_score=0
|
AND NOT numeric_score=0
|
||||||
";
|
";
|
||||||
$title = date("F Y", (strtotime($totaldate)));
|
$title = date("F Y", (strtotime($totaldate)));
|
||||||
@ -155,17 +153,21 @@ class NumericScore implements Extension {
|
|||||||
}
|
}
|
||||||
if($event->page_matches("popular_by_year")){
|
if($event->page_matches("popular_by_year")){
|
||||||
$sql .=
|
$sql .=
|
||||||
"WHERE YEAR(posted) =".$year."
|
"WHERE EXTRACT(YEAR FROM posted) = :year
|
||||||
AND NOT numeric_score=0
|
AND NOT numeric_score=0
|
||||||
";
|
";
|
||||||
$dte = array($totaldate, $year, "Y", "year");
|
$dte = array($totaldate, $year, "Y", "year");
|
||||||
}
|
}
|
||||||
$sql .=
|
$sql .= " ORDER BY numeric_score DESC LIMIT :limit OFFSET 0";
|
||||||
"ORDER BY numeric_score DESC
|
|
||||||
LIMIT 0 OFFSET ".$t_images;
|
|
||||||
|
|
||||||
//filter images by year/score != 0 > limit to max images on one page > order from highest to lowest score
|
//filter images by year/score != 0 > limit to max images on one page > order from highest to lowest score
|
||||||
$result = $database->get_all($sql);
|
$args = array(
|
||||||
|
"year" => $year,
|
||||||
|
"month" => $month,
|
||||||
|
"day" => $day,
|
||||||
|
"limit" => $t_images
|
||||||
|
);
|
||||||
|
$result = $database->get_all($sql, $args);
|
||||||
|
|
||||||
$images = array();
|
$images = array();
|
||||||
foreach($result as $singleResult) {
|
foreach($result as $singleResult) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user