mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
Added LIMIT-OFFSET clause for compatibility with PostgreSQL
http://www.postgresql.org/docs/current/static/sql-select.html#SQL-LIMIT
This commit is contained in:
parent
29f95933bf
commit
b6d705c147
@ -468,7 +468,11 @@ class Pastes extends CI_Model
|
||||
$total_rows = $query->num_rows();
|
||||
|
||||
// query
|
||||
if($this->db->dbdriver == "postgre") {
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $amount OFFSET $page";
|
||||
} else {
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $page,$amount";
|
||||
}
|
||||
$query = $this->db->query($sql, array(
|
||||
$search,
|
||||
$search,
|
||||
@ -483,7 +487,11 @@ class Pastes extends CI_Model
|
||||
$total_rows = $query->num_rows();
|
||||
|
||||
// query
|
||||
if($this->db->dbdriver == "postgre") {
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 ORDER BY created DESC LIMIT $amount OFFSET $page";
|
||||
} else {
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 ORDER BY created DESC LIMIT $page,$amount";
|
||||
}
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
@ -541,7 +549,11 @@ class Pastes extends CI_Model
|
||||
$total_rows = $query->num_rows();
|
||||
|
||||
// query
|
||||
if($this->db->dbdriver == "postgre") {
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT $amount OFFSET $page";
|
||||
} else {
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT $page,$amount";
|
||||
}
|
||||
$query = $this->db->query($sql, array(
|
||||
$search,
|
||||
$search,
|
||||
@ -556,7 +568,11 @@ class Pastes extends CI_Model
|
||||
$total_rows = $query->num_rows();
|
||||
|
||||
// query
|
||||
if($this->db->dbdriver == "postgre") {
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 ORDER BY hits DESC, created DESC LIMIT $amount OFFSET $page";
|
||||
} else {
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 ORDER BY hits DESC, created DESC LIMIT $page,$amount";
|
||||
}
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user