search optimisation

This commit is contained in:
Claude 2015-01-27 13:49:40 +01:00
parent 9ea9327a1d
commit 64a5a097d1

View File

@ -455,10 +455,11 @@ class Pastes extends CI_Model
$this->load->library('process'); $this->load->library('process');
$amount = $this->config->item('per_page'); $amount = $this->config->item('per_page');
$page = ($this->uri->segment($seg) ? $this->uri->segment($seg) : 0); $page = ($this->uri->segment($seg) ? $this->uri->segment($seg) : 0);
$search = '%' . $this->input->get('search') . '%'; $search = $this->input->get('search');
if ($search) if ($search)
{ {
$search = '%' . $search . '%';
// count total results // count total results
$sql = "SELECT id FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?)"; $sql = "SELECT id FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?)";
@ -549,10 +550,11 @@ class Pastes extends CI_Model
$this->load->library('pagination'); $this->load->library('pagination');
$amount = $this->config->item('per_page'); $amount = $this->config->item('per_page');
$page = ($this->uri->segment(2) ? $this->uri->segment(2) : 0); $page = ($this->uri->segment(2) ? $this->uri->segment(2) : 0);
$search = '%' . $this->input->get('search') . '%'; $search = $this->input->get('search');
if ($search) if ($search)
{ {
$search = '%' . $search . '%';
// count total results // count total results
$sql = "SELECT id FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?)"; $sql = "SELECT id FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?)";