Made sql read table name from config.php

This commit is contained in:
Peter Goodhall 2011-06-18 23:38:09 +01:00
parent a22c71b69b
commit de8b87e543

View File

@ -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;
}