mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Optimize index-usage
This commit is contained in:
@@ -325,12 +325,12 @@ class Contesting_model extends CI_Model {
|
||||
if ($from != 0) {
|
||||
$from = DateTime::createFromFormat('Y-m-d', $this->security->xss_clean($from));
|
||||
$from = $from->format('Y-m-d');
|
||||
$this->db->where("date(" . $this->config->item('table_name') . ".COL_TIME_ON) >= '" . $from . "'");
|
||||
$this->db->where($this->config->item('table_name') . ".COL_TIME_ON >= '" . $from . " 00:00:00'");
|
||||
}
|
||||
if ($to != 0) {
|
||||
$to = DateTime::createFromFormat('Y-m-d', $this->security->xss_clean($to));
|
||||
$to = $to->format('Y-m-d');
|
||||
$this->db->where("date(" . $this->config->item('table_name') . ".COL_TIME_ON) <= '" . $to . "'");
|
||||
$this->db->where($this->config->item('table_name') . ".COL_TIME_ON <= '" . $to . " 23:59:59'");
|
||||
}
|
||||
|
||||
// If band is set, we only load contacts for that band
|
||||
@@ -436,13 +436,13 @@ class Contesting_model extends CI_Model {
|
||||
$binding = [];
|
||||
$sql = "select distinct COL_BAND band
|
||||
from " . $this->config->item('table_name') . "
|
||||
where date(" . $this->config->item('table_name') . ".COL_TIME_ON) >= ?
|
||||
and date(" . $this->config->item('table_name') . ".COL_TIME_ON) <= ?
|
||||
where COL_TIME_ON >= ?
|
||||
and COL_TIME_ON <= ?
|
||||
and station_id = ? and COL_CONTEST_ID = ?";
|
||||
|
||||
//add data to bindings
|
||||
$binding[] = $from;
|
||||
$binding[] = $to;
|
||||
//add data to bindings - convert dates to datetime for index usage
|
||||
$binding[] = $from . ' 00:00:00';
|
||||
$binding[] = $to . ' 23:59:59';
|
||||
$binding[] = $station_id;
|
||||
$binding[] = $contestid;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user