From: Kevin Day Date: Wed, 16 Jan 2019 01:41:52 +0000 (-0600) Subject: Cleanup: Rename t_database_set to t_database_set_configuration_parameter X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=d6e4e0c0ee49eb43d0d686080c53da31c5226e9b;p=koopa Cleanup: Rename t_database_set to t_database_set_configuration_parameter --- diff --git a/common/database/classes/database_alter_database.php b/common/database/classes/database_alter_database.php index 7694439..8d0520b 100644 --- a/common/database/classes/database_alter_database.php +++ b/common/database/classes/database_alter_database.php @@ -9,7 +9,7 @@ require_once('common/base/classes/base_error.php'); require_once('common/base/classes/base_return.php'); require_once('common/database/enumerations/database_reset.php'); -require_once('common/database/enumerations/database_set.php'); +require_once('common/database/enumerations/database_set_configuration_parameter.php'); require_once('common/database/classes/database_query.php'); require_once('common/database/classes/database_string.php'); @@ -18,7 +18,7 @@ require_once('common/database/traits/database_name.php'); require_once('common/database/traits/database_rename_to.php'); require_once('common/database/traits/database_owner_to.php'); require_once('common/database/traits/database_set_tablespace.php'); -require_once('common/database/traits/database_set.php'); +require_once('common/database/traits/database_set_configuration_parameter.php'); require_once('common/database/traits/database_reset.php'); /** @@ -30,7 +30,7 @@ class c_database_alter_database extends c_database_query { use t_database_name; use t_database_rename_to; use t_database_owner_to; - use t_database_set; + use t_database_set_configuration_parameter; use t_database_set_tablespace; use t_database_reset; @@ -44,12 +44,12 @@ class c_database_alter_database extends c_database_query { public function __construct() { parent::__construct(); - $this->name = NULL; - $this->rename_to = NULL; - $this->owner_to = NULL; - $this->set = NULL; - $this->set_tablespace = NULL; - $this->reset = NULL; + $this->name = NULL; + $this->rename_to = NULL; + $this->owner_to = NULL; + $this->set_configuration_parameter = NULL; + $this->set_tablespace = NULL; + $this->reset = NULL; // TODO: it may be better (and more consistent) to convert option into a trait, just like all of the others. $this->option = NULL; @@ -62,7 +62,7 @@ class c_database_alter_database extends c_database_query { unset($this->name); unset($this->rename_to); unset($this->owner_to); - unset($this->set); + unset($this->set_configuration_parameter); unset($this->set_tablespace); unset($this->reset); @@ -101,7 +101,7 @@ class c_database_alter_database extends c_database_query { * * @return c_base_return_status * TRUE on success, FALSE otherwise. - * FALSE with error bit set is returned on error. + * FALSE with error bit set_configuration_parameter is returned on error. */ public function set_option($option) { if (is_null($option)) { @@ -123,7 +123,7 @@ class c_database_alter_database extends c_database_query { * * @return c_database_argument_database_option|c_base_return_null * The assigned option or NULL if not defined. - * NULL with the error bit set is returned on error. + * NULL with the error bit set_configuration_parameter is returned on error. */ public function get_option() { if (is_null($this->option)) { @@ -163,8 +163,8 @@ class c_database_alter_database extends c_database_query { else if (isset($this->set_tablespace)) { $value .= $this->p_do_build_set_tablespace(); } - else if (is_array($this->set)) { - $value .= $this->p_do_build_set(); + else if (is_array($this->set_configuration_parameter)) { + $value .= $this->p_do_build_set_configuration_parameter(); } else if (is_array($this->reset)) { $value .= $this->p_do_build_reset(); diff --git a/common/database/classes/database_alter_role.php b/common/database/classes/database_alter_role.php index 2bdf923..711a2d1 100644 --- a/common/database/classes/database_alter_role.php +++ b/common/database/classes/database_alter_role.php @@ -15,7 +15,7 @@ require_once('common/database/traits/database_name.php'); require_once('common/database/traits/database_rename_to.php'); require_once('common/database/traits/database_reset.php'); require_once('common/database/traits/database_role_specification.php'); -require_once('common/database/traits/database_set.php'); +require_once('common/database/traits/database_set_configuration_parameter.php'); require_once('common/database/traits/database_with_role_option.php'); @@ -31,7 +31,7 @@ class c_database_alter_role extends c_database_query { use t_database_reset; use t_database_role_option; use t_database_role_specification; - use t_database_set; + use t_database_set_configuration_parameter; protected const p_QUERY_COMMAND = 'alter role'; @@ -42,13 +42,13 @@ class c_database_alter_role extends c_database_query { public function __construct() { parent::__construct(); - $this->in_database = NULL; - $this->name = NULL; - $this->rename = NULL; - $this->reset = NULL; - $this->role_specification = NULL; - $this->set = NULL; - $this->with_role_option = NULL; + $this->in_database = NULL; + $this->name = NULL; + $this->rename = NULL; + $this->reset = NULL; + $this->role_specification = NULL; + $this->set_configuration_parameter = NULL; + $this->with_role_option = NULL; } /** @@ -60,7 +60,7 @@ class c_database_alter_role extends c_database_query { unset($this->rename); unset($this->reset); unset($this->role_specification); - unset($this->set); + unset($this->set_configuration_parameter); unset($this->with_role_option); parent::__destruct(); @@ -110,8 +110,8 @@ class c_database_alter_role extends c_database_query { $value .= ' ' . $this->p_do_build_in_database(); } - if (isset($this->set)) { - $value .= ' ' . $this->p_do_build_set(); + if (isset($this->set_configuration_parameter)) { + $value .= ' ' . $this->p_do_build_set_configuration_parameter(); } else if (isset($this->reset)) { $value .= ' ' . $this->p_do_build_reset(); diff --git a/common/database/classes/database_alter_subscription.php b/common/database/classes/database_alter_subscription.php index 29bf56e..37f9cef 100644 --- a/common/database/classes/database_alter_subscription.php +++ b/common/database/classes/database_alter_subscription.php @@ -17,7 +17,7 @@ require_once('common/database/traits/database_name.php'); require_once('common/database/traits/database_owner_to.php'); require_once('common/database/traits/database_refresh_publication.php'); require_once('common/database/traits/database_rename_to.php'); -require_once('common/database/traits/database_set.php'); +require_once('common/database/traits/database_set_configuration_parameter.php'); require_once('common/database/traits/database_set_publication_name.php'); require_once('common/database/traits/database_set_schema.php'); require_once('common/database/traits/database_with_publication_option.php'); @@ -37,7 +37,7 @@ class c_database_alter_subscription extends c_database_query { use t_database_owner_to; use t_database_refresh_publication; use t_database_rename_to; - use t_database_set; + use t_database_set_configuration_parameter; use t_database_set_publication_name; use t_database_set_schema; use t_database_with_publication_option; @@ -52,18 +52,18 @@ class c_database_alter_subscription extends c_database_query { public function __construct() { parent::__construct(); - $this->connection = NULL; - $this->disable = NULL; - $this->enable = NULL; - $this->name = NULL; - $this->owner_to = NULL; - $this->refresh_publication = NULL; - $this->rename_to = NULL; - $this->set = NULL; - $this->set_publication_name = NULL; - $this->set_schema = NULL; - $this->with_publication_option = NULL; - $this->with_refresh_option = NULL; + $this->connection = NULL; + $this->disable = NULL; + $this->enable = NULL; + $this->name = NULL; + $this->owner_to = NULL; + $this->refresh_publication = NULL; + $this->rename_to = NULL; + $this->set_configuration_parameter = NULL; + $this->set_publication_name = NULL; + $this->set_schema = NULL; + $this->with_publication_option = NULL; + $this->with_refresh_option = NULL; } /** @@ -77,7 +77,7 @@ class c_database_alter_subscription extends c_database_query { unset($this->owner_to); unset($this->refresh_publication); unset($this->rename_to); - unset($this->set); + unset($this->set_configuration_parameter); unset($this->set_publication_name); unset($this->set_schema); unset($this->with_publication_option); @@ -139,8 +139,8 @@ class c_database_alter_subscription extends c_database_query { else if (isset($this->disable)) { $value .= ' ' . $this->p_do_build_disable(); } - else if (isset($this->set)) { - $value .= ' ' . $this->p_do_build_set(); + else if (isset($this->set_configuration_parameter)) { + $value .= ' ' . $this->p_do_build_set_configuration_parameter(); } else if (isset($this->owner_to)) { $value .= ' ' . $this->p_do_build_owner_to(); diff --git a/common/database/classes/database_string.php b/common/database/classes/database_string.php index 373429d..73e0b42 100644 --- a/common/database/classes/database_string.php +++ b/common/database/classes/database_string.php @@ -200,6 +200,7 @@ class c_database_string { public const TRUNCATE = 'truncate'; public const TYPE = 'type'; public const TO = 'to'; + public const TO_DEFAULT = 'to default'; public const UNSAFE = 'unsafe'; public const UPDATE = 'update'; public const USAGE = 'usage'; diff --git a/common/database/enumerations/database_set.php b/common/database/enumerations/database_set.php index a40ea73..7138f8a 100644 --- a/common/database/enumerations/database_set.php +++ b/common/database/enumerations/database_set.php @@ -13,6 +13,7 @@ namespace n_koopa; class e_database_set { public const NONE = 0; public const TO = 1; - public const EQUAL = 2; - public const FROM_CURRENT = 3; + public const TO_DEFAULT = 2; + public const EQUAL = 3; + public const FROM_CURRENT = 4; } diff --git a/common/database/traits/database_connection.php b/common/database/traits/database_connection.php index e77f297..d5d8060 100644 --- a/common/database/traits/database_connection.php +++ b/common/database/traits/database_connection.php @@ -80,6 +80,6 @@ trait t_database_connection { * NULL is returned if there is nothing to process or there is an error. */ protected function p_do_build_connection() { - return c_database_string::CONNECTION . ' ' . strval($this->connection); + return c_database_string::CONNECTION . ' ' . $this->connection; } } diff --git a/common/database/traits/database_set.php b/common/database/traits/database_set_configuration_parameter.php similarity index 56% rename from common/database/traits/database_set.php rename to common/database/traits/database_set_configuration_parameter.php index 5aeee77..ae5a225 100644 --- a/common/database/traits/database_set.php +++ b/common/database/traits/database_set_configuration_parameter.php @@ -17,13 +17,13 @@ require_once('common/database/classes/database_string.php'); /** * Provide the sql SET functionality. */ -trait t_database_set { - protected $set; +trait t_database_set_configuration_parameter { + protected $set_configuration_parameter; /** - * Set the SET settings. + * Set the SET configuation parameter settings. * - * @param int|null $set + * @param int|null $type * The SET code to assign. * Should be one of: e_database_set. * Set to NULL to disable. @@ -39,18 +39,18 @@ trait t_database_set { * TRUE on success, FALSE otherwise. * FALSE with the error bit set is returned on error. */ - public function set_set($set, $parameter = NULL, $value = NULL) { - if (is_null($set)) { - $this->set = NULL; + public function set_set_configuration_parameter($type, $parameter = NULL, $value = NULL) { + if (is_null($type)) { + $this->set_configuration_parameter = NULL; return new c_base_return_true(); } - if (!is_int($set)) { - $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'set', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + if (!is_int($type)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); return c_base_return_error::s_false($error); } - if ($set === e_database_set::TO || $set === e_database_set::EQUAL) { + if ($type === e_database_set::TO || $type === e_database_set::EQUAL) { if (!is_string($parameter)) { $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); return c_base_return_error::s_false($error); @@ -66,8 +66,8 @@ trait t_database_set { return c_base_return_error::s_false($placeholder->get_error()); } - $set = [ - 'type' => $set, + $configuration_parameter = [ + 'type' => $type, 'parameter' => $placeholder, 'value' => NULL, ]; @@ -75,7 +75,7 @@ trait t_database_set { if (is_string($value)) { $placeholder = $this->add_placeholder($value); if ($placeholder->has_error()) { - unset($set); + unset($configuration_parameter); return c_base_return_error::s_false($placeholder->get_error()); } @@ -83,14 +83,14 @@ trait t_database_set { unset($placeholder); } - $this->set = $set; - unset($set); + $this->set_configuration_parameter = $configuration_parameter; + unset($configuration_parameter); return new c_base_return_true(); } - else if ($set == e_database_set::FROM_CURRENT) { - $this->set = [ - 'type' => $set, + else if ($type == e_database_set::FROM_CURRENT) { + $this->set_configuration_parameter = [ + 'type' => $type, 'parameter' => NULL, 'value' => NULL, ]; @@ -102,23 +102,23 @@ trait t_database_set { } /** - * Get the currently assigned set settings. + * Get the currently assigned set configuration parameter settings. * * @return c_base_return_array|c_base_return_null - * An array containing set settings on success. + * An array containing set configuration parameter settings on success. * NULL is returned if not set (set tablespace is not to be used). * NULL with the error bit set is returned on error. */ - public function get_set() { - if (is_null($this->set)) { + public function get_set_configuration_parameter() { + if (is_null($this->set_configuration_parameter)) { return new c_base_return_null(); } - if (is_array($this->set)) { - return c_base_return_array::s_new($this->set); + if (is_array($this->set_configuration_parameter)) { + return c_base_return_array::s_new($this->set_configuration_parameter); } - $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_configuration_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); return c_base_return_error::s_null($error); } @@ -131,28 +131,31 @@ trait t_database_set { * A string is returned on success. * NULL is returned if there is nothing to process or there is an error. */ - protected function p_do_build_set() { + protected function p_do_build_set_configuration_parameter() { $value = NULL; - if ($this->set['type'] === e_database_set::TO) { - $value = c_database_string::SET . ' ' . $this->set['parameter'] . ' ' . c_database_string::TO . ' '; - if (is_null($this->set['value'])) { + if ($this->set_configuration_parameter['type'] === e_database_set::TO) { + $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' ' . c_database_string::TO . ' '; + if (is_null($this->set_configuration_parameter['value'])) { $value .= c_database_string::DEFAULT; } else { - $value = $this->set['value']; + $value = $this->set_configuration_parameter['value']; } } - else if ($this->set['type'] === e_database_set::EQUAL) { - $value = c_database_string::SET . ' ' . $this->set['parameter'] . ' = '; - if (is_null($this->set['value'])) { + else if ($this->set_configuration_parameter['type'] === e_database_set::EQUAL) { + $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' = '; + if (is_null($this->set_configuration_parameter['value'])) { $value .= c_database_string::DEFAULT; } - else if (isset($this->set['parameter']) && isset($this->set['value'])) { - $value .= $this->set['value']; + else if (isset($this->set_configuration_parameter['parameter']) && isset($this->set_configuration_parameter['value'])) { + $value .= $this->set_configuration_parameter['value']; } } - else if ($this->set['type'] == e_database_set::FROM_CURRENT) { - $value = c_database_string::SET . ' ' . $this->set['parameter'] . ' = ' . c_database_string::FROM_CURRENT; + else if ($this->set_configuration_parameter['type'] == e_database_set::FROM_CURRENT) { + $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' = ' . c_database_string::FROM_CURRENT; + } + else if ($this->set_configuration_parameter['type'] == e_database_set::TO_DEFAULT) { + $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' ' . c_database_string::TO_DEFAULT; } return $value;