Fixed ghost pages again

This commit is contained in:
ruan 2016-09-09 18:14:09 +02:00
parent 1d9c7d9a5d
commit 3e7c7f8163

View File

@ -114,7 +114,6 @@ class Page {
function run_query() { function run_query() {
try { try {
$table = $this->table; $table = $this->table;
$where = $this->settings->active_query;
$limit = $this->settings->limit_per_page; $limit = $this->settings->limit_per_page;
$offset = 0; $offset = 0;
@ -125,11 +124,7 @@ class Page {
$sel = $this->get_selection($table); $sel = $this->get_selection($table);
if ($where !== "") { $where = $this->where_append($this->settings->active_query);
$where .= " AND ";
} else {
$where = "WHERE ";
}
$where .= "(uuid <> '#offline#' AND uuid IS NOT NULL)"; $where .= "(uuid <> '#offline#' AND uuid IS NOT NULL)";
$query = "SELECT $sel FROM $table $where GROUP BY $table.id ORDER BY time DESC LIMIT :limit OFFSET :offset"; $query = "SELECT $sel FROM $table $where GROUP BY $table.id ORDER BY time DESC LIMIT :limit OFFSET :offset";
@ -391,7 +386,10 @@ class Page {
$page = $this->name . ".php"; $page = $this->name . ".php";
if ($total === -1) { if ($total === -1) {
$result = $this->conn->query("SELECT COUNT(*) AS count FROM $table WHERE uuid <> '#offline#' AND uuid IS NOT NULL")->fetch(PDO::FETCH_ASSOC); $where = $this->where_append($this->settings->active_query);
$where .= "(uuid <> '#offline#' AND uuid IS NOT NULL)";
$result = $this->conn->query("SELECT COUNT(*) AS count FROM $table $where")->fetch(PDO::FETCH_ASSOC);
$total = $result['count']; $total = $result['count'];
} }
@ -450,4 +448,16 @@ class Page {
$str[0] = strtolower($str[0]); $str[0] = strtolower($str[0]);
return (string)$str; return (string)$str;
} }
/**
* @param $where
* @return string
*/
public function where_append($where) {
if ($where !== "") {
return $where . " AND ";
} else {
return "WHERE ";
}
}
} }