From de8b87e543d089b46fc8223509d275f1bdc790ab Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sat, 18 Jun 2011 23:38:09 +0100 Subject: [PATCH] Made sql read table name from config.php --- application/models/logbook_model.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php index 738bcd06..c82a9d19 100644 --- a/application/models/logbook_model.php +++ b/application/models/logbook_model.php @@ -28,13 +28,13 @@ class Logbook_model extends CI_Model { $morning = date('Y-m-d 00:00:00'); $night = date('Y-m-d 23:59:59'); - $query = $this->db->query('SELECT * FROM TABLE_HRD_CONTACTS_V01 WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); + $query = $this->db->query('SELECT * FROM '.$this->config->item('table_name').' WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); return $query; } function total_qsos() { - $query = $this->db->query('SELECT COUNT( * ) as count FROM TABLE_HRD_CONTACTS_V01'); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').''); if ($query->num_rows() > 0) { @@ -50,7 +50,7 @@ class Logbook_model extends CI_Model { $morning = date('Y-m-d 00:00:00'); $night = date('Y-m-d 23:59:59'); - $query = $this->db->query('SELECT COUNT( * ) as count FROM TABLE_HRD_CONTACTS_V01 WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); if ($query->num_rows() > 0) { @@ -65,7 +65,7 @@ class Logbook_model extends CI_Model { $morning = date('Y-m-01 00:00:00'); $night = date('Y-m-30 23:59:59'); - $query = $this->db->query('SELECT COUNT( * ) as count FROM TABLE_HRD_CONTACTS_V01 WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); if ($query->num_rows() > 0) { @@ -80,7 +80,7 @@ class Logbook_model extends CI_Model { $morning = date('Y-01-01 00:00:00'); $night = date('Y-12-31 23:59:59'); - $query = $this->db->query('SELECT COUNT( * ) as count FROM TABLE_HRD_CONTACTS_V01 WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); if ($query->num_rows() > 0) { @@ -93,7 +93,7 @@ class Logbook_model extends CI_Model { function total_ssb() { - $query = $this->db->query('SELECT COUNT( * ) as count FROM TABLE_HRD_CONTACTS_V01 WHERE COL_MODE = \'ssb\' or COL_MODE = \'lsb\' or COL_MODE = \'usb\''); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE = \'ssb\' or COL_MODE = \'lsb\' or COL_MODE = \'usb\''); if ($query->num_rows() > 0) { @@ -105,7 +105,7 @@ class Logbook_model extends CI_Model { } function total_cw() { - $query = $this->db->query('SELECT COUNT( * ) as count FROM TABLE_HRD_CONTACTS_V01 WHERE COL_MODE = \'cw\''); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE = \'cw\''); if ($query->num_rows() > 0) { @@ -117,7 +117,7 @@ class Logbook_model extends CI_Model { } function total_fm() { - $query = $this->db->query('SELECT COUNT( * ) as count FROM TABLE_HRD_CONTACTS_V01 WHERE COL_MODE = \'fm\''); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE = \'fm\''); if ($query->num_rows() > 0) { @@ -129,7 +129,7 @@ class Logbook_model extends CI_Model { } function total_digi() { - $query = $this->db->query('SELECT COUNT( * ) as count FROM TABLE_HRD_CONTACTS_V01 WHERE COL_MODE = \'psk31\' or COL_MODE = \'rtty\' or COL_MODE = \'psk63\' or COL_MODE = \'psk125\' or COL_MODE = \'JT65\''); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE = \'psk31\' or COL_MODE = \'rtty\' or COL_MODE = \'psk63\' or COL_MODE = \'psk125\' or COL_MODE = \'JT65\''); if ($query->num_rows() > 0) { @@ -141,7 +141,7 @@ class Logbook_model extends CI_Model { } function total_bands() { - $query = $this->db->query('SELECT DISTINCT (COL_BAND) AS band, count( * ) AS count FROM TABLE_HRD_CONTACTS_V01 GROUP BY band ORDER BY count DESC'); + $query = $this->db->query('SELECT DISTINCT (COL_BAND) AS band, count( * ) AS count FROM '.$this->config->item('table_name').' GROUP BY band ORDER BY count DESC'); return $query; }