From 6578b32dc89bc983af1f1e0f3d9154f78b30a2f3 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 2 May 2020 12:51:06 +0200 Subject: [PATCH] Removed hardcoded use of the database prefix. --- application/helpers/installation_helper.php | 2 +- .../001_initial_database_structure.php | 52 ++++----- .../migrations/009_change_column_types.php | 108 +++++++++--------- .../011_remove_prefix_from_foreign_keys.php | 104 ++++++++--------- ...014_create_appointment_location_column.php | 8 +- application/models/Admins_model.php | 6 +- application/models/Appointments_model.php | 4 +- application/models/Customers_model.php | 6 +- application/models/Providers_model.php | 8 +- application/models/Secretaries_model.php | 6 +- application/models/Services_model.php | 6 +- application/models/User_model.php | 2 +- 12 files changed, 156 insertions(+), 156 deletions(-) diff --git a/application/helpers/installation_helper.php b/application/helpers/installation_helper.php index 63c8bcac..e8f74b16 100644 --- a/application/helpers/installation_helper.php +++ b/application/helpers/installation_helper.php @@ -25,5 +25,5 @@ function is_ea_installed() { $framework =& get_instance(); - return $framework->db->table_exists('ea_users'); + return $framework->db->table_exists('users'); } diff --git a/application/migrations/001_initial_database_structure.php b/application/migrations/001_initial_database_structure.php index 78a29647..f22ee682 100644 --- a/application/migrations/001_initial_database_structure.php +++ b/application/migrations/001_initial_database_structure.php @@ -382,37 +382,37 @@ class Migration_Initial_database_structure extends CI_Migration { $this->dbforge->create_table('user_settings', TRUE, ['engine' => 'InnoDB']); $this->db->query(' - ALTER TABLE `ea_appointments` - ADD CONSTRAINT `ea_appointments_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_appointments_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_appointments_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + ALTER TABLE `' . $this->db->dbprefix('appointments') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; '); $this->db->query(' - ALTER TABLE `ea_secretaries_providers` - ADD CONSTRAINT `fk_ea_secretaries_providers_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `fk_ea_secretaries_providers_2` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` + ADD CONSTRAINT `fk_' . $this->db->dbprefix('secretaries_providers') . '_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `fk_' . $this->db->dbprefix('secretaries_providers') . '_2` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; '); $this->db->query(' - ALTER TABLE `ea_services` - ADD CONSTRAINT `ea_services_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `ea_service_categories` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; + ALTER TABLE `' . $this->db->dbprefix('services') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('services') . '_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `' . $this->db->dbprefix('service_categories') . '` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; '); $this->db->query(' - ALTER TABLE `ea_services_providers` - ADD CONSTRAINT `ea_services_providers_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_services_providers_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('services_providers') . '_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('services_providers') . '_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; '); $this->db->query(' - ALTER TABLE `ea_users` - ADD CONSTRAINT `ea_users_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `ea_roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + ALTER TABLE `' . $this->db->dbprefix('users') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('users') . '_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `' . $this->db->dbprefix('roles') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; '); $this->db->query(' - ALTER TABLE `ea_user_settings` - ADD CONSTRAINT `ea_user_settings_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('user_settings') . '_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; '); @@ -480,16 +480,16 @@ class Migration_Initial_database_structure extends CI_Migration { */ public function down() { - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_2`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_3`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_4`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_1`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_2`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_2`'); - $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `ea_services_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `ea_users_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `ea_user_settings_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_3`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_4`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `fk_' . $this->db->dbprefix('secretaries_providers') . '_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `fk_' . $this->db->dbprefix('secretaries_providers') . '_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services_providers') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services_providers') . '_ibfk_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('users') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('user_settings') . '_ibfk_1`'); $this->dbforge->drop_table('appointments'); $this->dbforge->drop_table('roles'); diff --git a/application/migrations/009_change_column_types.php b/application/migrations/009_change_column_types.php index 96eb08f5..54657720 100644 --- a/application/migrations/009_change_column_types.php +++ b/application/migrations/009_change_column_types.php @@ -24,16 +24,16 @@ class Migration_Change_column_types extends CI_Migration { public function up() { // Drop table constraints. - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_2`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_3`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_4`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_1`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_2`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_2`'); - $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `ea_services_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `ea_users_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `ea_user_settings_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_3`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_4`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `fk_' . $this->db->dbprefix('secretaries_providers') . '_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `fk_' . $this->db->dbprefix('secretaries_providers') . '_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services_providers') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services_providers') . '_ibfk_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('users') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('user_settings') . '_ibfk_1`'); // Appointments $fields = [ @@ -206,30 +206,30 @@ class Migration_Change_column_types extends CI_Migration { $this->dbforge->modify_column('user_settings', $fields); // Add table constraints again. - $this->db->query('ALTER TABLE `ea_appointments` - ADD CONSTRAINT `ea_appointments_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_appointments_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_appointments_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` - ADD CONSTRAINT `fk_ea_secretaries_providers_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `fk_ea_secretaries_providers_2` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` + ADD CONSTRAINT `fk_' . $this->db->dbprefix('secretaries_providers') . '_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `fk_' . $this->db->dbprefix('secretaries_providers') . '_2` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_services` - ADD CONSTRAINT `ea_services_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `ea_service_categories` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('services') . '_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `' . $this->db->dbprefix('service_categories') . '` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_services_providers` - ADD CONSTRAINT `ea_services_providers_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_services_providers_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('services_providers') . '_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('services_providers') . '_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_users` - ADD CONSTRAINT `ea_users_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `ea_roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('users') . '_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `' . $this->db->dbprefix('roles') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_user_settings` - ADD CONSTRAINT `ea_user_settings_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('user_settings') . '_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - // Change charset of ea_secretaries_providers table for databases created with EA! 1.2.1 version - $this->db->query('ALTER TABLE ea_secretaries_providers CONVERT TO CHARACTER SET utf8'); + // Change charset of ' . $this->db->dbprefix('secretaries_providers') . ' table for databases created with EA! 1.2.1 version + $this->db->query('ALTER TABLE ' . $this->db->dbprefix('secretaries_providers') . ' CONVERT TO CHARACTER SET utf8'); } /** @@ -238,16 +238,16 @@ class Migration_Change_column_types extends CI_Migration { public function down() { // Drop table constraints. - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_2`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_3`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_4`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_1`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_2`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_2`'); - $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `ea_services_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `ea_users_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `ea_user_settings_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_3`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_4`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `fk_' . $this->db->dbprefix('secretaries_providers') . '_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `fk_' . $this->db->dbprefix('secretaries_providers') . '_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services_providers') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services_providers') . '_ibfk_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('users') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('user_settings') . '_ibfk_1`'); // Appointments $fields = [ @@ -420,26 +420,26 @@ class Migration_Change_column_types extends CI_Migration { $this->dbforge->modify_column('user_settings', $fields); // Add database constraints. - $this->db->query('ALTER TABLE `ea_appointments` - ADD CONSTRAINT `ea_appointments_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_appointments_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_appointments_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` - ADD CONSTRAINT `fk_ea_secretaries_providers_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `fk_ea_secretaries_providers_2` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` + ADD CONSTRAINT `fk_' . $this->db->dbprefix('secretaries_providers') . '_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `fk_' . $this->db->dbprefix('secretaries_providers') . '_2` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_services` - ADD CONSTRAINT `ea_services_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `ea_service_categories` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('services') . '_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `' . $this->db->dbprefix('service_categories') . '` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_services_providers` - ADD CONSTRAINT `ea_services_providers_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_services_providers_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('services_providers') . '_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('services_providers') . '_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_users` - ADD CONSTRAINT `ea_users_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `ea_roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('users') . '_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `' . $this->db->dbprefix('roles') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_user_settings` - ADD CONSTRAINT `ea_user_settings_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('user_settings') . '_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); } } diff --git a/application/migrations/011_remove_prefix_from_foreign_keys.php b/application/migrations/011_remove_prefix_from_foreign_keys.php index 1503e7ff..6b5cec21 100644 --- a/application/migrations/011_remove_prefix_from_foreign_keys.php +++ b/application/migrations/011_remove_prefix_from_foreign_keys.php @@ -24,57 +24,57 @@ class Migration_Remove_prefix_from_foreign_keys extends CI_Migration { public function up() { // Drop table constraints. - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_2`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_3`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_4`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_1`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_2`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_2`'); - $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `ea_services_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `ea_users_ibfk_1`'); - $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `ea_user_settings_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_3`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('appointments') . '_ibfk_4`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `fk_' . $this->db->dbprefix('secretaries_providers') . '_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `fk_' . $this->db->dbprefix('secretaries_providers') . '_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services_providers') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services_providers') . '_ibfk_2`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('services') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('users') . '_ibfk_1`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` DROP FOREIGN KEY `' . $this->db->dbprefix('user_settings') . '_ibfk_1`'); // Add table constraints again without the "ea" prefix. - $this->db->query('ALTER TABLE `ea_appointments` - ADD CONSTRAINT `appointments_users_customer` FOREIGN KEY (`id_users_customer`) REFERENCES `ea_users` (`id`) + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` + ADD CONSTRAINT `appointments_users_customer` FOREIGN KEY (`id_users_customer`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `appointments_services` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) + ADD CONSTRAINT `appointments_services` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `appointments_users_provider` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) + ADD CONSTRAINT `appointments_users_provider` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` - ADD CONSTRAINT `secretaries_users_secretary` FOREIGN KEY (`id_users_secretary`) REFERENCES `ea_users` (`id`) + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` + ADD CONSTRAINT `secretaries_users_secretary` FOREIGN KEY (`id_users_secretary`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `secretaries_users_provider` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) + ADD CONSTRAINT `secretaries_users_provider` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_services` - ADD CONSTRAINT `services_service_categories` FOREIGN KEY (`id_service_categories`) REFERENCES `ea_service_categories` (`id`) + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` + ADD CONSTRAINT `services_service_categories` FOREIGN KEY (`id_service_categories`) REFERENCES `' . $this->db->dbprefix('service_categories') . '` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_services_providers` - ADD CONSTRAINT `services_providers_users_provider` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` + ADD CONSTRAINT `services_providers_users_provider` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `services_providers_services` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) + ADD CONSTRAINT `services_providers_services` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_users` - ADD CONSTRAINT `users_roles` FOREIGN KEY (`id_roles`) REFERENCES `ea_roles` (`id`) + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` + ADD CONSTRAINT `users_roles` FOREIGN KEY (`id_roles`) REFERENCES `' . $this->db->dbprefix('roles') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_user_settings` - ADD CONSTRAINT `user_settings_users` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` + ADD CONSTRAINT `user_settings_users` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); } @@ -85,38 +85,38 @@ class Migration_Remove_prefix_from_foreign_keys extends CI_Migration { public function down() { // Drop table constraints. - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `appointments_services`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `appointments_users_customer`'); - $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `appointments_users_provider`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `secretaries_users_secretary`'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `secretaries_users_provider`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `services_providers_users_provider`'); - $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `services_providers_services`'); - $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `services_service_categories`'); - $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `users_roles`'); - $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `user_settings_users`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `appointments_services`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `appointments_users_customer`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `appointments_users_provider`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `secretaries_users_secretary`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` DROP FOREIGN KEY `secretaries_users_provider`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `services_providers_users_provider`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` DROP FOREIGN KEY `services_providers_services`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` DROP FOREIGN KEY `services_service_categories`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` DROP FOREIGN KEY `users_roles`'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` DROP FOREIGN KEY `user_settings_users`'); // Add table constraints again. - $this->db->query('ALTER TABLE `ea_appointments` - ADD CONSTRAINT `ea_appointments_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_appointments_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_appointments_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('appointments') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('appointments') . '_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_secretaries_providers` - ADD CONSTRAINT `fk_ea_secretaries_providers_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `fk_ea_secretaries_providers_2` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('secretaries_providers') . '` + ADD CONSTRAINT `fk_' . $this->db->dbprefix('secretaries_providers') . '_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `fk_' . $this->db->dbprefix('secretaries_providers') . '_2` FOREIGN KEY (`id_users_provider`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_services` - ADD CONSTRAINT `ea_services_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `ea_service_categories` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('services') . '_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `' . $this->db->dbprefix('service_categories') . '` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_services_providers` - ADD CONSTRAINT `ea_services_providers_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `ea_services_providers_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('services_providers') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('services_providers') . '_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `' . $this->db->dbprefix('services_providers') . '_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `' . $this->db->dbprefix('services') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_users` - ADD CONSTRAINT `ea_users_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `ea_roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('users') . '_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `' . $this->db->dbprefix('roles') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); - $this->db->query('ALTER TABLE `ea_user_settings` - ADD CONSTRAINT `ea_user_settings_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + $this->db->query('ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` + ADD CONSTRAINT `' . $this->db->dbprefix('user_settings') . '_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' . $this->db->dbprefix('users') . '` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); } } diff --git a/application/migrations/014_create_appointment_location_column.php b/application/migrations/014_create_appointment_location_column.php index 7425102a..1b1436c6 100644 --- a/application/migrations/014_create_appointment_location_column.php +++ b/application/migrations/014_create_appointment_location_column.php @@ -24,12 +24,12 @@ class Migration_Create_appointment_location_column extends CI_Migration { public function up() { $this->db->query(' - ALTER TABLE `ea_appointments` + ALTER TABLE `' . $this->db->dbprefix('appointments') . '` ADD COLUMN `location` TEXT AFTER `end_datetime`; '); $this->db->query(' - ALTER TABLE `ea_services` + ALTER TABLE `' . $this->db->dbprefix('services') . '` ADD COLUMN `location` TEXT AFTER `description`; '); } @@ -40,12 +40,12 @@ class Migration_Create_appointment_location_column extends CI_Migration { public function down() { $this->db->query(' - ALTER TABLE `ea_appointments` + ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP COLUMN `location`; '); $this->db->query(' - ALTER TABLE `ea_services` + ALTER TABLE `' . $this->db->dbprefix('services') . '` DROP COLUMN `location`; '); } diff --git a/application/models/Admins_model.php b/application/models/Admins_model.php index cba9ce97..47efc9bc 100644 --- a/application/models/Admins_model.php +++ b/application/models/Admins_model.php @@ -139,7 +139,7 @@ class Admins_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('roles.slug', DB_SLUG_ADMIN) ->where('users.email', $admin['email']) ->where('users.id <>', $admin_id) @@ -190,7 +190,7 @@ class Admins_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.email', $admin['email']) ->where('roles.slug', DB_SLUG_ADMIN) ->get()->num_rows(); @@ -217,7 +217,7 @@ class Admins_Model extends CI_Model { $result = $this->db ->select('users.id') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.email', $admin['email']) ->where('roles.slug', DB_SLUG_ADMIN) ->get(); diff --git a/application/models/Appointments_model.php b/application/models/Appointments_model.php index 4a5a89ef..a1b7127b 100644 --- a/application/models/Appointments_model.php +++ b/application/models/Appointments_model.php @@ -90,7 +90,7 @@ class Appointments_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.id', $appointment['id_users_provider']) ->where('roles.slug', DB_SLUG_PROVIDER) ->get()->num_rows(); @@ -105,7 +105,7 @@ class Appointments_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.id', $appointment['id_users_customer']) ->where('roles.slug', DB_SLUG_CUSTOMER) ->get()->num_rows(); diff --git a/application/models/Customers_model.php b/application/models/Customers_model.php index f3683035..160dc681 100644 --- a/application/models/Customers_model.php +++ b/application/models/Customers_model.php @@ -109,7 +109,7 @@ class Customers_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('roles.slug', DB_SLUG_CUSTOMER) ->where('users.email', $customer['email']) ->where('users.id <>', $customer_id) @@ -149,7 +149,7 @@ class Customers_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.email', $customer['email']) ->where('roles.slug', DB_SLUG_CUSTOMER) ->get()->num_rows(); @@ -183,7 +183,7 @@ class Customers_Model extends CI_Model { $result = $this->db ->select('users.id') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.email', $customer['email']) ->where('roles.slug', DB_SLUG_CUSTOMER) ->get(); diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index 6be45ab0..367c34e4 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -177,7 +177,7 @@ class Providers_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('roles.slug', DB_SLUG_PROVIDER) ->where('users.email', $provider['email']) ->where('users.id <>', $provider_id) @@ -228,7 +228,7 @@ class Providers_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.email', $provider['email']) ->where('roles.slug', DB_SLUG_PROVIDER) ->get()->num_rows(); @@ -255,7 +255,7 @@ class Providers_Model extends CI_Model { $result = $this->db ->select('users.id') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.email', $provider['email']) ->where('roles.slug', DB_SLUG_PROVIDER) ->get(); @@ -627,7 +627,7 @@ class Providers_Model extends CI_Model { $this->db ->select('users.*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('roles.slug', DB_SLUG_PROVIDER) ->order_by('first_name ASC, last_name ASC, email ASC'); diff --git a/application/models/Secretaries_model.php b/application/models/Secretaries_model.php index 7bef4d44..a667e3a7 100644 --- a/application/models/Secretaries_model.php +++ b/application/models/Secretaries_model.php @@ -147,7 +147,7 @@ class Secretaries_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('roles.slug', DB_SLUG_SECRETARY) ->where('users.email', $secretary['email']) ->where('users.id <>', $secretary_id) @@ -198,7 +198,7 @@ class Secretaries_Model extends CI_Model { $num_rows = $this->db ->select('*') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.email', $secretary['email']) ->where('roles.slug', DB_SLUG_SECRETARY) ->get()->num_rows(); @@ -225,7 +225,7 @@ class Secretaries_Model extends CI_Model { $result = $this->db ->select('users.id') ->from('users') - ->join('roles', 'roles.id = ea_users.id_roles', 'inner') + ->join('roles', 'roles.id = users.id_roles', 'inner') ->where('users.email', $secretary['email']) ->where('roles.slug', DB_SLUG_SECRETARY) ->get(); diff --git a/application/models/Services_model.php b/application/models/Services_model.php index 48ef81ed..6768e9f3 100644 --- a/application/models/Services_model.php +++ b/application/models/Services_model.php @@ -339,13 +339,13 @@ class Services_Model extends CI_Model { { $this->db->distinct(); return $this->db - ->select('services.*, ea_service_categories.name AS category_name, ' + ->select('services.*, service_categories.name AS category_name, ' . 'service_categories.id AS category_id') ->from('services') ->join('services_providers', - 'services_providers.id_services = ea_services.id', 'inner') + 'services_providers.id_services = services.id', 'inner') ->join('service_categories', - 'service_categories.id = ea_services.id_service_categories', 'left') + 'service_categories.id = services.id_service_categories', 'left') ->order_by('name ASC') ->get()->result_array(); } diff --git a/application/models/User_model.php b/application/models/User_model.php index f2368d9f..6ed2b763 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -172,7 +172,7 @@ class User_Model extends CI_Model { $result = $this->db ->select('users.id') ->from('users') - ->join('user_settings', 'user_settings.id_users = ea_users.id', 'inner') + ->join('user_settings', 'user_settings.id_users = users.id', 'inner') ->where('users.email', $email) ->where('user_settings.username', $username) ->get();