From 9b787bbb1f194bcdbfed2e811749c1ea32c01010 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 28 Jan 2023 15:21:09 +0100 Subject: [PATCH] Fixed hardcoding of tables --- application/migrations/096_add_wwff_columns.php | 10 +++++----- application/migrations/108_add_pota_columns.php | 14 +++++++------- application/models/Activators_model.php | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/application/migrations/096_add_wwff_columns.php b/application/migrations/096_add_wwff_columns.php index 85c85eb9..b21d01db 100644 --- a/application/migrations/096_add_wwff_columns.php +++ b/application/migrations/096_add_wwff_columns.php @@ -14,12 +14,12 @@ class Migration_add_wwff_columns extends CI_Migration { public function up() { - if (!$this->db->field_exists('COL_WWFF_REF', 'TABLE_HRD_CONTACTS_V01')) { + if (!$this->db->field_exists('COL_WWFF_REF', $this->config->item('table_name'))) { $fields = array( 'COL_WWFF_REF VARCHAR(30) DEFAULT NULL', 'COL_MY_WWFF_REF VARCHAR(50) DEFAULT NULL', ); - $this->dbforge->add_column('TABLE_HRD_CONTACTS_V01', $fields, 'COL_VUCC_GRIDS'); + $this->dbforge->add_column($this->config->item('table_name'), $fields, 'COL_VUCC_GRIDS'); // Now copy over data from SIG_INFO fields and remove COL_SIG and COL_SIG_INFO only if COL_SIG is WWFF // This cannot be reverted on downgrade to prevent overwriting of other COL_SIG information @@ -27,7 +27,7 @@ class Migration_add_wwff_columns extends CI_Migration { $this->db->set('COL_SIG_INFO', ''); $this->db->set('COL_SIG', ''); $this->db->where('COL_SIG', 'WWFF'); - $this->db->update('TABLE_HRD_CONTACTS_V01'); + $this->db->update($this->config->item('table_name')); // Add MY_WWFF_REF to station profile $fields = array( @@ -39,8 +39,8 @@ class Migration_add_wwff_columns extends CI_Migration { public function down() { - $this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_WWFF_REF'); - $this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_MY_WWFF_REF'); + $this->dbforge->drop_column($this->config->item('table_name'), 'COL_WWFF_REF'); + $this->dbforge->drop_column($this->config->item('table_name'), 'COL_MY_WWFF_REF'); $this->dbforge->drop_column('station_profile', 'station_wwff'); } } diff --git a/application/migrations/108_add_pota_columns.php b/application/migrations/108_add_pota_columns.php index 2242fc7a..18a1ffe4 100644 --- a/application/migrations/108_add_pota_columns.php +++ b/application/migrations/108_add_pota_columns.php @@ -14,12 +14,12 @@ class Migration_add_pota_columns extends CI_Migration { public function up() { - if (!$this->db->field_exists('COL_POTA_REF', 'TABLE_HRD_CONTACTS_V01')) { + if (!$this->db->field_exists('COL_POTA_REF', $this->config->item('table_name'))) { $fields = array( 'COL_POTA_REF VARCHAR(30) DEFAULT NULL', 'COL_MY_POTA_REF VARCHAR(50) DEFAULT NULL', ); - $this->dbforge->add_column('TABLE_HRD_CONTACTS_V01', $fields, 'COL_VUCC_GRIDS'); + $this->dbforge->add_column($this->config->item('table_name'), $fields, 'COL_VUCC_GRIDS'); // Now copy over data from SIG_INFO fields and remove COL_SIG and COL_SIG_INFO only if COL_SIG is POTA // This cannot be reverted on downgrade to prevent overwriting of other COL_SIG information @@ -27,7 +27,7 @@ class Migration_add_pota_columns extends CI_Migration { $this->db->set('COL_SIG_INFO', ''); $this->db->set('COL_SIG', ''); $this->db->where('COL_SIG', 'POTA'); - $this->db->update('TABLE_HRD_CONTACTS_V01'); + $this->db->update($this->config->item('table_name')); } if (!$this->db->field_exists('station_pota', 'station_profile')) { @@ -52,11 +52,11 @@ class Migration_add_pota_columns extends CI_Migration { public function down() { - if ($this->db->field_exists('COL_POTA_REF', 'TABLE_HRD_CONTACTS_V01')) { - $this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_POTA_REF'); + if ($this->db->field_exists('COL_POTA_REF', $this->config->item('table_name'))) { + $this->dbforge->drop_column($this->config->item('table_name'), 'COL_POTA_REF'); } - if ($this->db->field_exists('COL_MY_POTA_REF', 'TABLE_HRD_CONTACTS_V01')) { - $this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_MY_POTA_REF'); + if ($this->db->field_exists('COL_MY_POTA_REF', $this->config->item('table_name'))) { + $this->dbforge->drop_column($this->config->item('table_name'), 'COL_MY_POTA_REF'); } if ($this->db->field_exists('station_pota', 'station_profile')) { $this->dbforge->drop_column('station_profile', 'station_pota'); diff --git a/application/models/Activators_model.php b/application/models/Activators_model.php index 981691e5..687fb6aa 100644 --- a/application/models/Activators_model.php +++ b/application/models/Activators_model.php @@ -105,7 +105,7 @@ class Activators_model extends CI_Model // Get max no of activated grids of single operator $data = $this->db->query( - "select COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count` from TABLE_HRD_CONTACTS_V01 WHERE station_id in (" . $location_list . ") AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` ORDER BY `count` DESC LIMIT 1" + "select COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count` from " . $this->config->item('table_name') . " WHERE station_id in (" . $location_list . ") AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` ORDER BY `count` DESC LIMIT 1" ); foreach($data->result() as $row){ $max = $row->count;