From 0620f00ea0cda2ff06fd401a78732a82f90d725a Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 10 Jan 2019 22:35:44 -0600 Subject: [PATCH] Progress: continue development on database abstraction --- .../database_alter_foreign_data_wrapper.php | 20 +- .../classes/database_alter_operator_class.php | 23 +- .../classes/database_alter_operator_family.php | 62 ++++- common/database/classes/database_alter_policy.php | 66 ++++- .../classes/database_alter_publication.php | 69 ++++- common/database/classes/database_alter_role.php | 85 ++++++- common/database/classes/database_alter_rule.php | 33 ++- common/database/classes/database_alter_schema.php | 44 +++- .../database/classes/database_alter_sequence.php | 184 ++++++++++++++ common/database/classes/database_alter_server.php | 115 +++++++++ .../database/classes/database_alter_statistics.php | 104 ++++++++ .../classes/database_alter_subscription.php | 162 ++++++++++++ common/database/classes/database_alter_system.php | 74 ++++++ common/database/classes/database_alter_table.php | 10 +- .../database/classes/database_alter_tablespace.php | 10 +- .../database_alter_text_search_configuration.php | 10 +- .../database_alter_text_search_dictionary.php | 10 +- .../classes/database_alter_text_search_parser.php | 10 +- .../database_alter_text_search_template.php | 10 +- common/database/classes/database_alter_trigger.php | 10 +- common/database/classes/database_alter_type.php | 10 +- common/database/classes/database_alter_user.php | 10 +- .../classes/database_alter_user_mapping.php | 10 +- common/database/classes/database_alter_view.php | 10 +- common/database/classes/database_analyze.php | 10 +- common/database/classes/database_begin.php | 10 +- common/database/classes/database_checkpoint.php | 10 +- common/database/classes/database_close.php | 10 +- common/database/classes/database_cluster.php | 10 +- common/database/classes/database_comment.php | 10 +- common/database/classes/database_commit.php | 10 +- .../database/classes/database_commit_prepared.php | 10 +- common/database/classes/database_copy.php | 10 +- .../classes/database_create_access_method.php | 10 +- .../database/classes/database_create_aggregate.php | 10 +- common/database/classes/database_create_cast.php | 10 +- .../database/classes/database_create_collation.php | 10 +- .../classes/database_create_conversion.php | 10 +- .../database/classes/database_create_database.php | 10 +- common/database/classes/database_create_domain.php | 10 +- .../classes/database_create_event_trigger.php | 10 +- .../database/classes/database_create_extension.php | 10 +- .../database/classes/database_create_foreign.php | 10 +- .../database_create_foreign_data_wrapper.php | 10 +- .../database/classes/database_create_function.php | 10 +- common/database/classes/database_create_group.php | 10 +- common/database/classes/database_create_index.php | 10 +- .../database/classes/database_create_language.php | 10 +- .../classes/database_create_materialized_view.php | 10 +- .../database/classes/database_create_operator.php | 10 +- .../classes/database_create_operator_class.php | 10 +- .../classes/database_create_operator_family.php | 10 +- common/database/classes/database_create_policy.php | 10 +- .../classes/database_create_publication.php | 10 +- common/database/classes/database_create_role.php | 10 +- common/database/classes/database_create_rule.php | 10 +- common/database/classes/database_create_schema.php | 10 +- .../database/classes/database_create_sequence.php | 10 +- common/database/classes/database_create_server.php | 10 +- .../classes/database_create_statistics.php | 10 +- .../classes/database_create_subscription.php | 10 +- common/database/classes/database_create_table.php | 10 +- .../database/classes/database_create_table_as.php | 10 +- .../classes/database_create_tablespace.php | 10 +- .../database_create_text_search_configuration.php | 10 +- .../database_create_text_search_dictionary.php | 10 +- .../classes/database_create_text_search_parser.php | 10 +- .../database_create_text_search_template.php | 10 +- .../database/classes/database_create_transform.php | 10 +- common/database/classes/database_create_user.php | 10 +- .../classes/database_create_user_mapping.php | 10 +- common/database/classes/database_create_view.php | 10 +- common/database/classes/database_deallocate.php | 10 +- common/database/classes/database_declare.php | 10 +- common/database/classes/database_delete.php | 10 +- common/database/classes/database_discard.php | 10 +- common/database/classes/database_do.php | 10 +- .../classes/database_drop_access_method.php | 10 +- .../database/classes/database_drop_aggregate.php | 10 +- common/database/classes/database_drop_cast.php | 10 +- .../database/classes/database_drop_collation.php | 10 +- .../database/classes/database_drop_conversion.php | 10 +- common/database/classes/database_drop_database.php | 10 +- common/database/classes/database_drop_domain.php | 10 +- .../classes/database_drop_event_trigger.php | 10 +- .../database/classes/database_drop_extension.php | 10 +- .../classes/database_drop_foreign_data_wrapper.php | 10 +- .../classes/database_drop_foreign_table.php | 10 +- common/database/classes/database_drop_function.php | 10 +- common/database/classes/database_drop_group.php | 10 +- common/database/classes/database_drop_index.php | 10 +- common/database/classes/database_drop_language.php | 10 +- .../classes/database_drop_materialized_view.php | 10 +- common/database/classes/database_drop_operator.php | 10 +- .../classes/database_drop_operator_class.php | 10 +- .../classes/database_drop_operator_family.php | 10 +- common/database/classes/database_drop_owned.php | 10 +- common/database/classes/database_drop_policy.php | 10 +- .../database/classes/database_drop_publication.php | 10 +- common/database/classes/database_drop_role.php | 10 +- common/database/classes/database_drop_rule.php | 10 +- common/database/classes/database_drop_schema.php | 10 +- common/database/classes/database_drop_sequence.php | 10 +- common/database/classes/database_drop_server.php | 10 +- .../database/classes/database_drop_statistics.php | 10 +- .../classes/database_drop_subscription.php | 10 +- common/database/classes/database_drop_table.php | 10 +- .../database/classes/database_drop_tablespace.php | 10 +- .../database_drop_text_search_configuration.php | 10 +- .../database_drop_text_search_dictionary.php | 10 +- .../classes/database_drop_text_search_parser.php | 10 +- .../classes/database_drop_text_search_template.php | 10 +- .../database/classes/database_drop_transform.php | 10 +- common/database/classes/database_drop_trigger.php | 10 +- common/database/classes/database_drop_type.php | 10 +- common/database/classes/database_drop_user.php | 10 +- .../classes/database_drop_user_mapping.php | 10 +- common/database/classes/database_drop_view.php | 10 +- common/database/classes/database_end.php | 10 +- common/database/classes/database_execute.php | 10 +- common/database/classes/database_explain.php | 10 +- common/database/classes/database_fetch.php | 10 +- common/database/classes/database_grant.php | 10 +- .../classes/database_import_foreign_schema.php | 10 +- common/database/classes/database_insert.php | 10 +- common/database/classes/database_listen.php | 10 +- common/database/classes/database_load.php | 10 +- common/database/classes/database_lock.php | 10 +- common/database/classes/database_move.php | 10 +- common/database/classes/database_notify.php | 10 +- common/database/classes/database_prepare.php | 10 +- .../classes/database_prepare_transaction.php | 10 +- .../database/classes/database_reassign_owned.php | 10 +- .../classes/database_refresh_materialized.php | 10 +- common/database/classes/database_reindex.php | 10 +- .../classes/database_release_savepoint.php | 10 +- common/database/classes/database_reset.php | 10 +- common/database/classes/database_revoke.php | 10 +- .../classes/database_rollback_prepared.php | 10 +- .../classes/database_rollback_to_savepoint.php | 10 +- common/database/classes/database_savepoint.php | 10 +- .../database/classes/database_security_label.php | 10 +- common/database/classes/database_select.php | 10 +- common/database/classes/database_select_into.php | 10 +- common/database/classes/database_set.php | 10 +- .../database/classes/database_set_constraints.php | 10 +- common/database/classes/database_set_role.php | 10 +- .../classes/database_set_session_authorization.php | 10 +- .../database/classes/database_set_transaction.php | 10 +- common/database/classes/database_show.php | 10 +- .../classes/database_start_transaction.php | 10 +- common/database/classes/database_string.php | 50 +++- common/database/classes/database_truncate.php | 10 +- common/database/classes/database_unlisten.php | 10 +- common/database/classes/database_update.php | 10 +- common/database/classes/database_vacuum.php | 10 +- common/database/classes/database_values.php | 10 +- .../enumerations/database_operator_family.php | 17 ++ .../enumerations/database_operator_for.php | 17 ++ .../enumerations/database_publication_option.php | 16 ++ .../database_publication_parameter.php | 16 ++ .../enumerations/database_publication_value.php | 18 ++ .../enumerations/database_refresh_option.php | 16 ++ common/database/enumerations/database_role.php | 7 +- .../database/enumerations/database_role_option.php | 33 +++ .../enumerations/database_storage_parameter.php | 6 +- .../database_subscription_parameter.php | 21 ++ .../traits/database_add_operator_family.php | 279 +++++++++++++++++++++ common/database/traits/database_add_table.php | 132 ++++++++++ common/database/traits/database_add_user.php | 2 +- common/database/traits/database_argument_type.php | 2 +- common/database/traits/database_as_data_type.php | 85 +++++++ common/database/traits/database_cache.php | 79 ++++++ common/database/traits/database_cluster_on.php | 8 +- common/database/traits/database_connection.php | 85 +++++++ common/database/traits/database_cycle.php | 83 ++++++ common/database/traits/database_disable.php | 82 ++++++ common/database/traits/database_drop_table.php | 132 ++++++++++ common/database/traits/database_enable.php | 82 ++++++ common/database/traits/database_in_database.php | 85 +++++++ common/database/traits/database_increment_by.php | 78 ++++++ common/database/traits/database_max_value.php | 87 +++++++ common/database/traits/database_min_value.php | 87 +++++++ common/database/traits/database_oid.php | 76 +----- .../{database_using.php => database_on_table.php} | 44 ++-- common/database/traits/database_owned_by.php | 15 +- .../traits/database_refresh_publication.php | 79 ++++++ .../traits/database_reset_storage_parameter.php | 14 +- common/database/traits/database_restart_with.php | 83 ++++++ .../traits/database_role_specification.php | 15 +- .../traits/database_set_publication_name.php | 98 ++++++++ .../traits/database_set_publication_parameter.php | 148 +++++++++++ common/database/traits/database_set_schema.php | 4 +- .../traits/database_set_storage_parameter.php | 40 +-- common/database/traits/database_set_table.php | 132 ++++++++++ common/database/traits/database_start_with.php | 78 ++++++ .../database/traits/database_using_expression.php | 80 ++++++ .../traits/database_using_index_method.php | 85 +++++++ common/database/traits/database_version.php | 85 +++++++ .../traits/database_with_check_expression.php | 80 ++++++ .../traits/database_with_publication_option.php | 135 ++++++++++ .../traits/database_with_refresh_option.php | 135 ++++++++++ .../database/traits/database_with_role_option.php | 209 +++++++++++++++ .../traits/database_with_storage_parameter.php | 152 +++++++++++ 204 files changed, 5373 insertions(+), 490 deletions(-) create mode 100644 common/database/classes/database_alter_sequence.php create mode 100644 common/database/classes/database_alter_server.php create mode 100644 common/database/classes/database_alter_statistics.php create mode 100644 common/database/classes/database_alter_subscription.php create mode 100644 common/database/classes/database_alter_system.php create mode 100644 common/database/enumerations/database_operator_family.php create mode 100644 common/database/enumerations/database_operator_for.php create mode 100644 common/database/enumerations/database_publication_option.php create mode 100644 common/database/enumerations/database_publication_parameter.php create mode 100644 common/database/enumerations/database_publication_value.php create mode 100644 common/database/enumerations/database_refresh_option.php create mode 100644 common/database/enumerations/database_role_option.php create mode 100644 common/database/enumerations/database_subscription_parameter.php create mode 100644 common/database/traits/database_add_operator_family.php create mode 100644 common/database/traits/database_add_table.php create mode 100644 common/database/traits/database_as_data_type.php create mode 100644 common/database/traits/database_cache.php create mode 100644 common/database/traits/database_connection.php create mode 100644 common/database/traits/database_cycle.php create mode 100644 common/database/traits/database_disable.php create mode 100644 common/database/traits/database_drop_table.php create mode 100644 common/database/traits/database_enable.php create mode 100644 common/database/traits/database_in_database.php create mode 100644 common/database/traits/database_increment_by.php create mode 100644 common/database/traits/database_max_value.php create mode 100644 common/database/traits/database_min_value.php rename common/database/traits/{database_using.php => database_on_table.php} (60%) create mode 100644 common/database/traits/database_refresh_publication.php create mode 100644 common/database/traits/database_restart_with.php create mode 100644 common/database/traits/database_set_publication_name.php create mode 100644 common/database/traits/database_set_publication_parameter.php create mode 100644 common/database/traits/database_set_table.php create mode 100644 common/database/traits/database_start_with.php create mode 100644 common/database/traits/database_using_expression.php create mode 100644 common/database/traits/database_using_index_method.php create mode 100644 common/database/traits/database_version.php create mode 100644 common/database/traits/database_with_check_expression.php create mode 100644 common/database/traits/database_with_publication_option.php create mode 100644 common/database/traits/database_with_refresh_option.php create mode 100644 common/database/traits/database_with_role_option.php create mode 100644 common/database/traits/database_with_storage_parameter.php diff --git a/common/database/classes/database_alter_foreign_data_wrapper.php b/common/database/classes/database_alter_foreign_data_wrapper.php index 58b7f0e..4a2c7ed 100644 --- a/common/database/classes/database_alter_foreign_data_wrapper.php +++ b/common/database/classes/database_alter_foreign_data_wrapper.php @@ -94,41 +94,41 @@ class c_database_alter_foreign_data_wrapper extends c_database_query { return new c_base_return_false(); } - $action = NULL; + $value = NULL; if ($this->action === e_database_action::OWNER_TO) { if (isset($this->owner_to)) { - $action = $this->p_do_build_owner_to(); + $value = $this->p_do_build_owner_to(); } else { - unset($action); + unset($value); return new c_base_return_false(); } } else if ($this->action === e_database_action::RENAME_TO) { if (isset($this->rename_to)) { - $action = $this->p_do_build_rename_to(); + $value = $this->p_do_build_rename_to(); } else { - unset($action); + unset($value); return new c_base_return_false(); } } else { if (is_array($this->handler)) { - $action .= ' ' . $this->p_do_build_handler(); + $value .= ' ' . $this->p_do_build_handler(); } if (is_array($this->validator)) { - $action .= ' ' . $this->p_do_build_validator(); + $value .= ' ' . $this->p_do_build_validator(); } - $actions .= ' ' . $this->p_do_build_options(); + $value .= ' ' . $this->p_do_build_options(); } $this->value = static::p_QUERY_COMMAND; $this->value .= ' ' . $this->p_do_build_name(); - $this->value .= ' ' . $action; - unset($action); + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_operator_class.php b/common/database/classes/database_alter_operator_class.php index d3cd98a..b94a2df 100644 --- a/common/database/classes/database_alter_operator_class.php +++ b/common/database/classes/database_alter_operator_class.php @@ -12,8 +12,9 @@ require_once('common/database/classes/database_query.php'); require_once('common/database/traits/database_name.php'); require_once('common/database/traits/database_owner_to.php'); +require_once('common/database/traits/database_rename_to.php'); require_once('common/database/traits/database_set_schema.php'); -require_once('common/database/traits/database_using.php'); +require_once('common/database/traits/database_using_index_method.php'); /** @@ -24,8 +25,9 @@ require_once('common/database/traits/database_using.php'); class c_database_alter_operator_class extends c_database_query { use t_database_name; use t_database_owner_to; + use t_database_rename_to; use t_database_set_schema; - use t_database_using; + use t_database_using_index_method; protected const p_QUERY_COMMAND = 'alter operator class'; @@ -35,12 +37,24 @@ class c_database_alter_operator_class extends c_database_query { */ public function __construct() { parent::__construct(); + + $this->name = NULL; + $this->owner_to = NULL; + $this->rename_to = NULL; + $this->set_schema = NULL; + $this->using_index_method = NULL; } /** * Class destructor. */ public function __destruct() { + unset($this->name); + unset($this->owner_to); + unset($this->rename_to); + unset($this->set_schema); + unset($this->using_index_method); + parent::__destruct(); } @@ -73,10 +87,13 @@ class c_database_alter_operator_class extends c_database_query { return new c_base_return_false(); } - $value = $this->p_do_build_name() . ' ' . $this->p_do_build_using(); + $value = $this->p_do_build_name() . ' ' . $this->p_do_build_using_index_method(); if (isset($this->set_schema)) { $value .= ' ' . $this->p_do_build_set_schema(); } + else if (isset($this->rename_to)) { + $value .= ' ' . $this->p_do_build_rename_to(); + } else if (isset($this->owner_to)) { $value .= ' ' . $this->p_do_build_owner_to(); } diff --git a/common/database/classes/database_alter_operator_family.php b/common/database/classes/database_alter_operator_family.php index 54885a7..34e965c 100644 --- a/common/database/classes/database_alter_operator_family.php +++ b/common/database/classes/database_alter_operator_family.php @@ -10,14 +10,28 @@ require_once('common/base/classes/base_return.php'); require_once('common/database/classes/database_query.php'); +require_once('common/database/traits/database_add_operator_family.php'); +require_once('common/database/traits/database_name.php'); +require_once('common/database/traits/database_owner_to.php'); +require_once('common/database/traits/database_rename_to.php'); +require_once('common/database/traits/database_set_schema.php'); +require_once('common/database/traits/database_using_index_method.php'); + /** - * The class for building and returning a Postgresql ALTER COALATION query string. + * The class for building and returning a Postgresql ALTER OPERATOR FAMILY query string. * - * @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html + * @see: https://www.postgresql.org/docs/current/static/sql-alteroperatofamily.html */ -class c_database_alter_coalation extends c_database_query { - protected const p_QUERY_COMMAND = 'alter coalation'; +class c_database_alter_operator_family extends c_database_query { + use t_database_add_operator_family; + use t_database_name; + use t_database_owner_to; + use t_database_rename_to; + use t_database_set_schema; + use t_database_using_index_method; + + protected const p_QUERY_COMMAND = 'alter operator family'; /** @@ -25,12 +39,26 @@ class c_database_alter_coalation extends c_database_query { */ public function __construct() { parent::__construct(); + + $this->add_operator_family = NULL; + $this->name = NULL; + $this->owner_to = NULL; + $this->rename_to = NULL; + $this->set_schema = NULL; + $this->using_index_method = NULL; } /** * Class destructor. */ public function __destruct() { + unset($this->add_operator_family); + unset($this->name); + unset($this->owner_to); + unset($this->rename_to); + unset($this->set_schema); + unset($this->using_index_method); + parent::__destruct(); } @@ -59,9 +87,31 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name) || !isset($this->using)) { + return new c_base_return_false(); + } + + $value = $this->p_do_build_name() . ' ' . $this->p_do_build_using_index_method(); + if (isset($this->add_operator_family)) { + $value .= ' ' . $this->p_do_build_add_operator_family(); + } + else if (isset($this->set_schema)) { + $value .= ' ' . $this->p_do_build_set_schema(); + } + else if (isset($this->rename_to)) { + $value .= ' ' . $this->p_do_build_rename_to(); + } + else if (isset($this->owner_to)) { + $value .= ' ' . $this->p_do_build_owner_to(); + } + else { + unset($value); + return new c_base_return_false(); + } - // @todo + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_policy.php b/common/database/classes/database_alter_policy.php index 54885a7..4977ed5 100644 --- a/common/database/classes/database_alter_policy.php +++ b/common/database/classes/database_alter_policy.php @@ -1,7 +1,7 @@ name = NULL; + $this->on_table = NULL; + $this->rename_to = NULL; + $this->to_role = NULL; + $this->using_expression = NULL; + $this->with_check_expression = NULL; } /** * Class destructor. */ public function __destruct() { + unset($this->name); + unset($this->on_table); + unset($this->rename_to); + unset($this->to_role); + unset($this->using_expression); + unset($this->with_check_expression); + parent::__destruct(); } @@ -59,9 +87,33 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name) || !isset($this->on_table)) { + return new c_base_return_false(); + } + + $value = $this->p_do_build_name() . ' ' . $this->p_do_build_on_table(); + if (isset($this->rename_to)) { + $value .= ' ' . $this->p_do_build_rename_to(); + } + else if (isset($this->to_role)) { + $value .= ' ' . $this->p_do_build_to_role(); + + if (isset($this->using_expression)) { + $value .= ' ' . $this->p_do_build_using_expression(); + } + + if (isset($this->with_check_expression)) { + $value .= ' ' . $this->p_do_build_with_check_expression(); + } + } + else { + unset($value); + return new c_base_return_false(); + } - // @todo + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_publication.php b/common/database/classes/database_alter_publication.php index 54885a7..8ae5ba9 100644 --- a/common/database/classes/database_alter_publication.php +++ b/common/database/classes/database_alter_publication.php @@ -1,7 +1,7 @@ add_table = NULL; + $this->drop_table = NULL; + $this->name = NULL; + $this->owner_to = NULL; + $this->rename_to = NULL; + $this->set_table = NULL; } /** * Class destructor. */ public function __destruct() { + unset($this->add_table); + unset($this->drop_table); + unset($this->name); + unset($this->owner_to); + unset($this->rename_to); + unset($this->set_table); + parent::__destruct(); } @@ -59,9 +87,36 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } + + $value = $this->p_do_build_name(); + + + if (isset($this->add_table)) { + $value .= ' ' . $this->p_do_build_add_table(); + } + else if (isset($this->drop_table)) { + $value .= ' ' . $this->p_do_build_drop_table(); + } + else if (isset($this->owner_to)) { + $value .= ' ' . $this->p_do_build_owner_to(); + } + else if (isset($this->rename_to)) { + $value .= ' ' . $this->p_do_build_rename_to(); + } + else if (isset($this->set_table)) { + $value .= ' ' . $this->p_do_build_set_table(); + } + else { + unset($value); + return new c_base_return_false(); + } - // @todo + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_role.php b/common/database/classes/database_alter_role.php index 54885a7..2bdf923 100644 --- a/common/database/classes/database_alter_role.php +++ b/common/database/classes/database_alter_role.php @@ -1,7 +1,7 @@ in_database = NULL; + $this->name = NULL; + $this->rename = NULL; + $this->reset = NULL; + $this->role_specification = NULL; + $this->set = NULL; + $this->with_role_option = NULL; } /** * Class destructor. */ public function __destruct() { + unset($this->in_database); + unset($this->name); + unset($this->rename); + unset($this->reset); + unset($this->role_specification); + unset($this->set); + unset($this->with_role_option); + parent::__destruct(); } @@ -59,9 +91,48 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->role_specification) && is_null($this->name)) { + return new c_base_return_false(); + } + + if (isset($this->role_specification)) { + $value = $this->p_do_build_role_specification(); + + if (isset($this->with_role_option)) { + $value .= ' ' . $this->p_do_build_with_role_option(); + } + else { + unset($value); + return new c_base_return_false(); + } + + if (isset($this->in_database)) { + $value .= ' ' . $this->p_do_build_in_database(); + } + + if (isset($this->set)) { + $value .= ' ' . $this->p_do_build_set(); + } + else if (isset($this->reset)) { + $value .= ' ' . $this->p_do_build_reset(); + } + else { + unset($value); + return new c_base_return_false(); + } + } + else if (isset($this->rename_to)) { + $value = $this->p_do_build_name(); + $value .= ' ' . $this->p_do_build_rename_to(); + } + else { + unset($value); + return new c_base_return_false(); + } - // @todo + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_rule.php b/common/database/classes/database_alter_rule.php index 54885a7..be9d92b 100644 --- a/common/database/classes/database_alter_rule.php +++ b/common/database/classes/database_alter_rule.php @@ -10,14 +10,22 @@ require_once('common/base/classes/base_return.php'); require_once('common/database/classes/database_query.php'); +require_once('common/database/traits/database_name.php'); +require_once('common/database/traits/database_on_table.php'); +require_once('common/database/traits/database_rename_to.php'); + /** - * The class for building and returning a Postgresql ALTER COALATION query string. + * The class for building and returning a Postgresql ALTER RULE query string. * - * @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html + * @see: https://www.postgresql.org/docs/current/static/sql-alterrule.html */ -class c_database_alter_coalation extends c_database_query { - protected const p_QUERY_COMMAND = 'alter coalation'; +class c_database_alter_rule extends c_database_query { + use t_database_name; + use t_database_on_table; + use t_database_rename_to; + + protected const p_QUERY_COMMAND = 'alter rule'; /** @@ -25,12 +33,20 @@ class c_database_alter_coalation extends c_database_query { */ public function __construct() { parent::__construct(); + + $this->name = NULL; + $this->on_table = NULL; + $this->rename_to = NULL; } /** * Class destructor. */ public function __destruct() { + unset($this->name); + unset($this->on_table); + unset($this->rename_to); + parent::__destruct(); } @@ -59,9 +75,14 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name) || is_null($this->on_table) || is_null($this->rename_to)) { + return new c_base_return_false(); + } - // @todo + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $this->p_do_build_name(); + $this->value .= ' ' . $this->p_do_build_on_table(); + $this->value .= ' ' . $this->p_do_build_rename_to(); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_schema.php b/common/database/classes/database_alter_schema.php index 54885a7..12cd8f4 100644 --- a/common/database/classes/database_alter_schema.php +++ b/common/database/classes/database_alter_schema.php @@ -10,14 +10,22 @@ require_once('common/base/classes/base_return.php'); require_once('common/database/classes/database_query.php'); +require_once('common/database/traits/database_name.php'); +require_once('common/database/traits/database_owner_to.php'); +require_once('common/database/traits/database_rename_to.php'); + /** - * The class for building and returning a Postgresql ALTER COALATION query string. + * The class for building and returning a Postgresql ALTER SCHEMA query string. * - * @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html + * @see: https://www.postgresql.org/docs/current/static/sql-alterschema.html */ -class c_database_alter_coalation extends c_database_query { - protected const p_QUERY_COMMAND = 'alter coalation'; +class c_database_alter_schema extends c_database_query { + use t_database_name; + use t_database_owner_to; + use t_database_rename_to; + + protected const p_QUERY_COMMAND = 'alter schema'; /** @@ -25,12 +33,20 @@ class c_database_alter_coalation extends c_database_query { */ public function __construct() { parent::__construct(); + + $this->name = NULL; + $this->owner_to = NULL; + $this->rename_to = NULL; } /** * Class destructor. */ public function __destruct() { + unset($this->name); + unset($this->owner_to); + unset($this->rename_to); + parent::__destruct(); } @@ -59,9 +75,25 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } + + $value = $this->p_do_build_name(); + if (isset($this->owner_to)) { + $value .= ' ' . $this->p_do_build_owner_to(); + } + else if (isset($this->rename_to)) { + $value .= ' ' . $this->p_do_build_rename_to(); + } + else { + unset($value); + return new c_base_return_false(); + } - // @todo + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_sequence.php b/common/database/classes/database_alter_sequence.php new file mode 100644 index 0000000..d521828 --- /dev/null +++ b/common/database/classes/database_alter_sequence.php @@ -0,0 +1,184 @@ +as_data_type = NULL; + $this->cache = NULL; + $this->cycle = NULL; + $this->if_exists = NULL; + $this->increment_by = NULL; + $this->max_value = NULL; + $this->min_value = NULL; + $this->name = NULL; + $this->owned_by = NULL; + $this->owner_to = NULL; + $this->rename_to = NULL; + $this->restart_with = NULL; + $this->set_schema = NULL; + $this->start_with = NULL; + } + + /** + * Class destructor. + */ + public function __destruct() { + unset($this->as_data_type); + unset($this->cache); + unset($this->cycle); + unset($this->if_exists); + unset($this->increment_by); + unset($this->max_value); + unset($this->min_value); + unset($this->name); + unset($this->owned_by); + unset($this->owner_to); + unset($this->rename_to); + unset($this->restart_with); + unset($this->set_schema); + unset($this->start_with); + + parent::__destruct(); + } + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, ''); + } + + /** + * Implements do_build(). + */ + public function do_build() { + if (is_null($this->name)) { + return new c_base_return_false(); + } + + $value = $this->p_do_build_name(); + if (isset($this->if_exists)) { + $value = $this->p_do_build_if_exists() . ' ' . $value; + } + + if (isset($this->owner_to)) { + $value .= ' ' . $this->p_do_build_owner_to(); + } + else if (isset($this->rename_to)) { + $value .= ' ' . $this->p_do_build_rename_to(); + } + else if (isset($this->set_schema)) { + $value .= ' ' . $this->p_do_build_set_schema(); + } + else { + if (isset($this->as_data_type)) { + $value .= ' ' . $this->p_do_build_as_data_type(); + } + + if (isset($this->increment_by)) { + $value .= ' ' . $this->p_do_build_increment_by(); + } + + if (isset($this->min_value)) { + $value .= ' ' . $this->p_do_build_min_value(); + } + + if (isset($this->max_value)) { + $value .= ' ' . $this->p_do_build_max_value(); + } + + if (isset($this->start_with)) { + $value .= ' ' . $this->p_do_build_start_with(); + } + + if (isset($this->restart_with)) { + $value .= ' ' . $this->p_do_build_restart_with(); + } + + if (isset($this->cache)) { + $value .= ' ' . $this->p_do_build_cache(); + } + + if (isset($this->cycle)) { + $value .= ' ' . $this->p_do_build_cycle(); + } + + if (isset($this->owned_by)) { + $value .= ' ' . $this->p_do_build_owned_by(); + } + } + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); + + return new c_base_return_true(); + } +} diff --git a/common/database/classes/database_alter_server.php b/common/database/classes/database_alter_server.php new file mode 100644 index 0000000..8a015cc --- /dev/null +++ b/common/database/classes/database_alter_server.php @@ -0,0 +1,115 @@ +name = NULL; + $this->options = NULL; + $this->owner_to = NULL; + $this->rename_to = NULL; + $this->version = NULL; + } + + /** + * Class destructor. + */ + public function __destruct() { + unset($this->name); + unset($this->options); + unset($this->owner_to); + unset($this->rename_to); + unset($this->version); + + parent::__destruct(); + } + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, ''); + } + + /** + * Implements do_build(). + */ + public function do_build() { + if (is_null($this->name)) { + return new c_base_return_false(); + } + + $value = $this->p_do_build_name(); + + if (isset($this->options)) { + if (isset($this->version)) { + $value .= ' ' . $this->p_do_build_version(); + } + $value .= ' ' . $this->p_do_build_options(); + } + else if (isset($this->owner_to)) { + $value .= ' ' . $this->p_do_build_owner_to(); + } + else if (isset($this->rename_to)) { + $value .= ' ' . $this->p_do_build_rename_to(); + } + else { + unset($value); + return new c_base_return_false(); + } + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); + + return new c_base_return_true(); + } +} diff --git a/common/database/classes/database_alter_statistics.php b/common/database/classes/database_alter_statistics.php new file mode 100644 index 0000000..66bf971 --- /dev/null +++ b/common/database/classes/database_alter_statistics.php @@ -0,0 +1,104 @@ +name = NULL; + $this->rename_to = NULL; + $this->set_schema = NULL; + } + + /** + * Class destructor. + */ + public function __destruct() { + unset($this->name); + unset($this->rename_to); + unset($this->set_schema); + + parent::__destruct(); + } + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, ''); + } + + /** + * Implements do_build(). + */ + public function do_build() { + if (is_null($this->name)) { + return new c_base_return_false(); + } + + $value = $this->p_do_build_name(); + + if (isset($this->owner_to)) { + $value .= ' ' . $this->p_do_build_owner_to(); + } + else if (isset($this->rename_to)) { + $value .= ' ' . $this->p_do_build_rename_to(); + } + else if (isset($this->set_schema)) { + $value .= ' ' . $this->p_do_build_set_schema(); + } + else { + unset($value); + return new c_base_return_false(); + } + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); + + return new c_base_return_true(); + } +} diff --git a/common/database/classes/database_alter_subscription.php b/common/database/classes/database_alter_subscription.php new file mode 100644 index 0000000..29bf56e --- /dev/null +++ b/common/database/classes/database_alter_subscription.php @@ -0,0 +1,162 @@ +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; + } + + /** + * Class destructor. + */ + public function __destruct() { + unset($this->connection); + unset($this->disable); + unset($this->enable); + unset($this->name); + unset($this->owner_to); + unset($this->refresh_publication); + unset($this->rename_to); + unset($this->set); + unset($this->set_publication_name); + unset($this->set_schema); + unset($this->with_publication_option); + unset($this->with_refresh_option); + + parent::__destruct(); + } + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, ''); + } + + /** + * Implements do_build(). + */ + public function do_build() { + if (is_null($this->name)) { + return new c_base_return_false(); + } + + $value = $this->p_do_build_name(); + if (isset($this->connection)) { + $value .= ' ' . $this->p_do_build_connection(); + } + else if (isset($this->set_publication_name)) { + $value .= ' ' . $this->p_do_build_set_publication_name(); + + if (isset($this->with_publication_option)) { + $value .= ' ' . $this->p_do_build_with_publication_option(); + } + } + else if (isset($this->refresh_publication)) { + $value .= ' ' . $this->p_do_build_refresh_publication(); + + if (isset($this->with_refresh_option)) { + $value .= ' ' . $this->p_do_build_with_refresh_option(); + } + } + else if (isset($this->enable)) { + $value .= ' ' . $this->p_do_build_enable(); + } + 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->owner_to)) { + $value .= ' ' . $this->p_do_build_owner_to(); + } + else if (isset($this->rename_to)) { + $value .= ' ' . $this->p_do_build_rename_to(); + } + else { + unset($value); + return new c_base_return_false(); + } + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); + + return new c_base_return_true(); + } +} diff --git a/common/database/classes/database_alter_system.php b/common/database/classes/database_alter_system.php new file mode 100644 index 0000000..bf3857e --- /dev/null +++ b/common/database/classes/database_alter_system.php @@ -0,0 +1,74 @@ +name)) { + return new c_base_return_false(); + } + + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); + + return new c_base_return_true(); + } +} diff --git a/common/database/classes/database_alter_table.php b/common/database/classes/database_alter_table.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_table.php +++ b/common/database/classes/database_alter_table.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_tablespace.php b/common/database/classes/database_alter_tablespace.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_tablespace.php +++ b/common/database/classes/database_alter_tablespace.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_text_search_configuration.php b/common/database/classes/database_alter_text_search_configuration.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_text_search_configuration.php +++ b/common/database/classes/database_alter_text_search_configuration.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_text_search_dictionary.php b/common/database/classes/database_alter_text_search_dictionary.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_text_search_dictionary.php +++ b/common/database/classes/database_alter_text_search_dictionary.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_text_search_parser.php b/common/database/classes/database_alter_text_search_parser.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_text_search_parser.php +++ b/common/database/classes/database_alter_text_search_parser.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_text_search_template.php b/common/database/classes/database_alter_text_search_template.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_text_search_template.php +++ b/common/database/classes/database_alter_text_search_template.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_trigger.php b/common/database/classes/database_alter_trigger.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_trigger.php +++ b/common/database/classes/database_alter_trigger.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_type.php b/common/database/classes/database_alter_type.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_type.php +++ b/common/database/classes/database_alter_type.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_user.php b/common/database/classes/database_alter_user.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_user.php +++ b/common/database/classes/database_alter_user.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_user_mapping.php b/common/database/classes/database_alter_user_mapping.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_user_mapping.php +++ b/common/database/classes/database_alter_user_mapping.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_alter_view.php b/common/database/classes/database_alter_view.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_alter_view.php +++ b/common/database/classes/database_alter_view.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_analyze.php b/common/database/classes/database_analyze.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_analyze.php +++ b/common/database/classes/database_analyze.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_begin.php b/common/database/classes/database_begin.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_begin.php +++ b/common/database/classes/database_begin.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_checkpoint.php b/common/database/classes/database_checkpoint.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_checkpoint.php +++ b/common/database/classes/database_checkpoint.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_close.php b/common/database/classes/database_close.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_close.php +++ b/common/database/classes/database_close.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_cluster.php b/common/database/classes/database_cluster.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_cluster.php +++ b/common/database/classes/database_cluster.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_comment.php b/common/database/classes/database_comment.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_comment.php +++ b/common/database/classes/database_comment.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_commit.php b/common/database/classes/database_commit.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_commit.php +++ b/common/database/classes/database_commit.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_commit_prepared.php b/common/database/classes/database_commit_prepared.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_commit_prepared.php +++ b/common/database/classes/database_commit_prepared.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_copy.php b/common/database/classes/database_copy.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_copy.php +++ b/common/database/classes/database_copy.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_access_method.php b/common/database/classes/database_create_access_method.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_access_method.php +++ b/common/database/classes/database_create_access_method.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_aggregate.php b/common/database/classes/database_create_aggregate.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_aggregate.php +++ b/common/database/classes/database_create_aggregate.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_cast.php b/common/database/classes/database_create_cast.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_cast.php +++ b/common/database/classes/database_create_cast.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_collation.php b/common/database/classes/database_create_collation.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_collation.php +++ b/common/database/classes/database_create_collation.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_conversion.php b/common/database/classes/database_create_conversion.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_conversion.php +++ b/common/database/classes/database_create_conversion.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_database.php b/common/database/classes/database_create_database.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_database.php +++ b/common/database/classes/database_create_database.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_domain.php b/common/database/classes/database_create_domain.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_domain.php +++ b/common/database/classes/database_create_domain.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_event_trigger.php b/common/database/classes/database_create_event_trigger.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_event_trigger.php +++ b/common/database/classes/database_create_event_trigger.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_extension.php b/common/database/classes/database_create_extension.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_extension.php +++ b/common/database/classes/database_create_extension.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_foreign.php b/common/database/classes/database_create_foreign.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_foreign.php +++ b/common/database/classes/database_create_foreign.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_foreign_data_wrapper.php b/common/database/classes/database_create_foreign_data_wrapper.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_foreign_data_wrapper.php +++ b/common/database/classes/database_create_foreign_data_wrapper.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_function.php b/common/database/classes/database_create_function.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_function.php +++ b/common/database/classes/database_create_function.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_group.php b/common/database/classes/database_create_group.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_group.php +++ b/common/database/classes/database_create_group.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_index.php b/common/database/classes/database_create_index.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_index.php +++ b/common/database/classes/database_create_index.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_language.php b/common/database/classes/database_create_language.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_language.php +++ b/common/database/classes/database_create_language.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_materialized_view.php b/common/database/classes/database_create_materialized_view.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_materialized_view.php +++ b/common/database/classes/database_create_materialized_view.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_operator.php b/common/database/classes/database_create_operator.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_operator.php +++ b/common/database/classes/database_create_operator.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_operator_class.php b/common/database/classes/database_create_operator_class.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_operator_class.php +++ b/common/database/classes/database_create_operator_class.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_operator_family.php b/common/database/classes/database_create_operator_family.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_operator_family.php +++ b/common/database/classes/database_create_operator_family.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_policy.php b/common/database/classes/database_create_policy.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_policy.php +++ b/common/database/classes/database_create_policy.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_publication.php b/common/database/classes/database_create_publication.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_publication.php +++ b/common/database/classes/database_create_publication.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_role.php b/common/database/classes/database_create_role.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_role.php +++ b/common/database/classes/database_create_role.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_rule.php b/common/database/classes/database_create_rule.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_rule.php +++ b/common/database/classes/database_create_rule.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_schema.php b/common/database/classes/database_create_schema.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_schema.php +++ b/common/database/classes/database_create_schema.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_sequence.php b/common/database/classes/database_create_sequence.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_sequence.php +++ b/common/database/classes/database_create_sequence.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_server.php b/common/database/classes/database_create_server.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_server.php +++ b/common/database/classes/database_create_server.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_statistics.php b/common/database/classes/database_create_statistics.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_statistics.php +++ b/common/database/classes/database_create_statistics.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_subscription.php b/common/database/classes/database_create_subscription.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_subscription.php +++ b/common/database/classes/database_create_subscription.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_table.php b/common/database/classes/database_create_table.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_table.php +++ b/common/database/classes/database_create_table.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_table_as.php b/common/database/classes/database_create_table_as.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_table_as.php +++ b/common/database/classes/database_create_table_as.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_tablespace.php b/common/database/classes/database_create_tablespace.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_tablespace.php +++ b/common/database/classes/database_create_tablespace.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_text_search_configuration.php b/common/database/classes/database_create_text_search_configuration.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_text_search_configuration.php +++ b/common/database/classes/database_create_text_search_configuration.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_text_search_dictionary.php b/common/database/classes/database_create_text_search_dictionary.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_text_search_dictionary.php +++ b/common/database/classes/database_create_text_search_dictionary.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_text_search_parser.php b/common/database/classes/database_create_text_search_parser.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_text_search_parser.php +++ b/common/database/classes/database_create_text_search_parser.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_text_search_template.php b/common/database/classes/database_create_text_search_template.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_text_search_template.php +++ b/common/database/classes/database_create_text_search_template.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_transform.php b/common/database/classes/database_create_transform.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_transform.php +++ b/common/database/classes/database_create_transform.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_user.php b/common/database/classes/database_create_user.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_user.php +++ b/common/database/classes/database_create_user.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_user_mapping.php b/common/database/classes/database_create_user_mapping.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_user_mapping.php +++ b/common/database/classes/database_create_user_mapping.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_create_view.php b/common/database/classes/database_create_view.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_create_view.php +++ b/common/database/classes/database_create_view.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_deallocate.php b/common/database/classes/database_deallocate.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_deallocate.php +++ b/common/database/classes/database_deallocate.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_declare.php b/common/database/classes/database_declare.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_declare.php +++ b/common/database/classes/database_declare.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_delete.php b/common/database/classes/database_delete.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_delete.php +++ b/common/database/classes/database_delete.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_discard.php b/common/database/classes/database_discard.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_discard.php +++ b/common/database/classes/database_discard.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_do.php b/common/database/classes/database_do.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_do.php +++ b/common/database/classes/database_do.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_access_method.php b/common/database/classes/database_drop_access_method.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_access_method.php +++ b/common/database/classes/database_drop_access_method.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_aggregate.php b/common/database/classes/database_drop_aggregate.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_aggregate.php +++ b/common/database/classes/database_drop_aggregate.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_cast.php b/common/database/classes/database_drop_cast.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_cast.php +++ b/common/database/classes/database_drop_cast.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_collation.php b/common/database/classes/database_drop_collation.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_collation.php +++ b/common/database/classes/database_drop_collation.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_conversion.php b/common/database/classes/database_drop_conversion.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_conversion.php +++ b/common/database/classes/database_drop_conversion.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_database.php b/common/database/classes/database_drop_database.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_database.php +++ b/common/database/classes/database_drop_database.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_domain.php b/common/database/classes/database_drop_domain.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_domain.php +++ b/common/database/classes/database_drop_domain.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_event_trigger.php b/common/database/classes/database_drop_event_trigger.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_event_trigger.php +++ b/common/database/classes/database_drop_event_trigger.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_extension.php b/common/database/classes/database_drop_extension.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_extension.php +++ b/common/database/classes/database_drop_extension.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_foreign_data_wrapper.php b/common/database/classes/database_drop_foreign_data_wrapper.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_foreign_data_wrapper.php +++ b/common/database/classes/database_drop_foreign_data_wrapper.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_foreign_table.php b/common/database/classes/database_drop_foreign_table.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_foreign_table.php +++ b/common/database/classes/database_drop_foreign_table.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_function.php b/common/database/classes/database_drop_function.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_function.php +++ b/common/database/classes/database_drop_function.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_group.php b/common/database/classes/database_drop_group.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_group.php +++ b/common/database/classes/database_drop_group.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_index.php b/common/database/classes/database_drop_index.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_index.php +++ b/common/database/classes/database_drop_index.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_language.php b/common/database/classes/database_drop_language.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_language.php +++ b/common/database/classes/database_drop_language.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_materialized_view.php b/common/database/classes/database_drop_materialized_view.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_materialized_view.php +++ b/common/database/classes/database_drop_materialized_view.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_operator.php b/common/database/classes/database_drop_operator.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_operator.php +++ b/common/database/classes/database_drop_operator.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_operator_class.php b/common/database/classes/database_drop_operator_class.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_operator_class.php +++ b/common/database/classes/database_drop_operator_class.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_operator_family.php b/common/database/classes/database_drop_operator_family.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_operator_family.php +++ b/common/database/classes/database_drop_operator_family.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_owned.php b/common/database/classes/database_drop_owned.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_owned.php +++ b/common/database/classes/database_drop_owned.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_policy.php b/common/database/classes/database_drop_policy.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_policy.php +++ b/common/database/classes/database_drop_policy.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_publication.php b/common/database/classes/database_drop_publication.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_publication.php +++ b/common/database/classes/database_drop_publication.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_role.php b/common/database/classes/database_drop_role.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_role.php +++ b/common/database/classes/database_drop_role.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_rule.php b/common/database/classes/database_drop_rule.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_rule.php +++ b/common/database/classes/database_drop_rule.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_schema.php b/common/database/classes/database_drop_schema.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_schema.php +++ b/common/database/classes/database_drop_schema.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_sequence.php b/common/database/classes/database_drop_sequence.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_sequence.php +++ b/common/database/classes/database_drop_sequence.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_server.php b/common/database/classes/database_drop_server.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_server.php +++ b/common/database/classes/database_drop_server.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_statistics.php b/common/database/classes/database_drop_statistics.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_statistics.php +++ b/common/database/classes/database_drop_statistics.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_subscription.php b/common/database/classes/database_drop_subscription.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_subscription.php +++ b/common/database/classes/database_drop_subscription.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_table.php b/common/database/classes/database_drop_table.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_table.php +++ b/common/database/classes/database_drop_table.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_tablespace.php b/common/database/classes/database_drop_tablespace.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_tablespace.php +++ b/common/database/classes/database_drop_tablespace.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_text_search_configuration.php b/common/database/classes/database_drop_text_search_configuration.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_text_search_configuration.php +++ b/common/database/classes/database_drop_text_search_configuration.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_text_search_dictionary.php b/common/database/classes/database_drop_text_search_dictionary.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_text_search_dictionary.php +++ b/common/database/classes/database_drop_text_search_dictionary.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_text_search_parser.php b/common/database/classes/database_drop_text_search_parser.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_text_search_parser.php +++ b/common/database/classes/database_drop_text_search_parser.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_text_search_template.php b/common/database/classes/database_drop_text_search_template.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_text_search_template.php +++ b/common/database/classes/database_drop_text_search_template.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_transform.php b/common/database/classes/database_drop_transform.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_transform.php +++ b/common/database/classes/database_drop_transform.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_trigger.php b/common/database/classes/database_drop_trigger.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_trigger.php +++ b/common/database/classes/database_drop_trigger.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_type.php b/common/database/classes/database_drop_type.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_type.php +++ b/common/database/classes/database_drop_type.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_user.php b/common/database/classes/database_drop_user.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_user.php +++ b/common/database/classes/database_drop_user.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_user_mapping.php b/common/database/classes/database_drop_user_mapping.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_user_mapping.php +++ b/common/database/classes/database_drop_user_mapping.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_drop_view.php b/common/database/classes/database_drop_view.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_drop_view.php +++ b/common/database/classes/database_drop_view.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_end.php b/common/database/classes/database_end.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_end.php +++ b/common/database/classes/database_end.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_execute.php b/common/database/classes/database_execute.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_execute.php +++ b/common/database/classes/database_execute.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_explain.php b/common/database/classes/database_explain.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_explain.php +++ b/common/database/classes/database_explain.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_fetch.php b/common/database/classes/database_fetch.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_fetch.php +++ b/common/database/classes/database_fetch.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_grant.php b/common/database/classes/database_grant.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_grant.php +++ b/common/database/classes/database_grant.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_import_foreign_schema.php b/common/database/classes/database_import_foreign_schema.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_import_foreign_schema.php +++ b/common/database/classes/database_import_foreign_schema.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_insert.php b/common/database/classes/database_insert.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_insert.php +++ b/common/database/classes/database_insert.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_listen.php b/common/database/classes/database_listen.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_listen.php +++ b/common/database/classes/database_listen.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_load.php b/common/database/classes/database_load.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_load.php +++ b/common/database/classes/database_load.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_lock.php b/common/database/classes/database_lock.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_lock.php +++ b/common/database/classes/database_lock.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_move.php b/common/database/classes/database_move.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_move.php +++ b/common/database/classes/database_move.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_notify.php b/common/database/classes/database_notify.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_notify.php +++ b/common/database/classes/database_notify.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_prepare.php b/common/database/classes/database_prepare.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_prepare.php +++ b/common/database/classes/database_prepare.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_prepare_transaction.php b/common/database/classes/database_prepare_transaction.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_prepare_transaction.php +++ b/common/database/classes/database_prepare_transaction.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_reassign_owned.php b/common/database/classes/database_reassign_owned.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_reassign_owned.php +++ b/common/database/classes/database_reassign_owned.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_refresh_materialized.php b/common/database/classes/database_refresh_materialized.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_refresh_materialized.php +++ b/common/database/classes/database_refresh_materialized.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_reindex.php b/common/database/classes/database_reindex.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_reindex.php +++ b/common/database/classes/database_reindex.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_release_savepoint.php b/common/database/classes/database_release_savepoint.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_release_savepoint.php +++ b/common/database/classes/database_release_savepoint.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_reset.php b/common/database/classes/database_reset.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_reset.php +++ b/common/database/classes/database_reset.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_revoke.php b/common/database/classes/database_revoke.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_revoke.php +++ b/common/database/classes/database_revoke.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_rollback_prepared.php b/common/database/classes/database_rollback_prepared.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_rollback_prepared.php +++ b/common/database/classes/database_rollback_prepared.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_rollback_to_savepoint.php b/common/database/classes/database_rollback_to_savepoint.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_rollback_to_savepoint.php +++ b/common/database/classes/database_rollback_to_savepoint.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_savepoint.php b/common/database/classes/database_savepoint.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_savepoint.php +++ b/common/database/classes/database_savepoint.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_security_label.php b/common/database/classes/database_security_label.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_security_label.php +++ b/common/database/classes/database_security_label.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_select.php b/common/database/classes/database_select.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_select.php +++ b/common/database/classes/database_select.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_select_into.php b/common/database/classes/database_select_into.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_select_into.php +++ b/common/database/classes/database_select_into.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_set.php b/common/database/classes/database_set.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_set.php +++ b/common/database/classes/database_set.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_set_constraints.php b/common/database/classes/database_set_constraints.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_set_constraints.php +++ b/common/database/classes/database_set_constraints.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_set_role.php b/common/database/classes/database_set_role.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_set_role.php +++ b/common/database/classes/database_set_role.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_set_session_authorization.php b/common/database/classes/database_set_session_authorization.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_set_session_authorization.php +++ b/common/database/classes/database_set_session_authorization.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_set_transaction.php b/common/database/classes/database_set_transaction.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_set_transaction.php +++ b/common/database/classes/database_set_transaction.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_show.php b/common/database/classes/database_show.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_show.php +++ b/common/database/classes/database_show.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_start_transaction.php b/common/database/classes/database_start_transaction.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_start_transaction.php +++ b/common/database/classes/database_start_transaction.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_string.php b/common/database/classes/database_string.php index 0d77039..373429d 100644 --- a/common/database/classes/database_string.php +++ b/common/database/classes/database_string.php @@ -13,6 +13,7 @@ namespace n_koopa; class c_database_string { public const ACCESS_METHOD = 'access method'; public const ADD = 'add'; + public const ADD_TABLE = 'add table'; public const AGGREGATE = 'aggregate'; public const ALL = 'all'; public const ALLOW_CONNECTIONS = 'allow_connections'; @@ -32,26 +33,39 @@ class c_database_string { public const AUTOVACUUM_MULTIXACT_FREEZE_TABLE_AGE = 'autovacuum_multixact_freeze_table_age'; public const AUTOVACUUM_SCALE_FACTOR = 'autovacuum_scale_factor'; public const AUTOVACUUM_VACUUM_THRESHOLD = 'autovacuum_vacuum_threshold'; + public const BYPASSRLS = 'bypassrls'; public const BUFFERING = 'buffering'; + public const CACHE = 'cache'; public const CALLED_ON_NULL_INPUT = 'called on null input'; public const CASCADE = 'cascade'; public const CAST = 'cast'; public const CLUSTER_ON = 'cluster on'; public const COLLATION = 'collation'; public const COLUMN = 'column'; + public const CONNECT = 'connect'; + public const CONNECTION = 'connection'; public const CONNECTION_LIMIT = 'connection limit'; public const CONVERSION = 'conversion'; + public const COPY_DATA = 'copy_data'; public const COST = 'cost'; public const CREATE = 'create'; + public const CREATEDB = 'createdb'; + public const CREATEROLE = 'createrole'; + public const CREATE_SLOT = 'create_slot'; + public const CYCLE = 'cycle'; public const DEFAULT = 'default'; public const DELETE = 'delete'; public const DEPENDS_ON_EXTENSION = 'depends on extension'; public const DESCEND = 'desc'; + public const DISABLE = 'disable'; public const DISABLE_TRIGGER = 'disable trigger'; public const DOMAIN = 'domain'; public const DROP = 'drop'; + public const DROP_TABLE = 'drop table'; public const DROP_CONSTRAINT = 'drop constraint'; public const DROP_DEFAULT = 'drop default'; + public const ENABLE = 'enable'; + public const ENABLED = 'enabled'; public const ENABLE_ALWAYS_TRIGGER = 'enable always trigger'; public const ENABLE_REPLICA_TRIGGER = 'enable replica trigger'; public const ENABLE_TRIGGER = 'enable trigger'; @@ -60,12 +74,14 @@ class c_database_string { public const EXTENDED = 'extended'; public const EXTERNAL = 'external'; public const FALSE = 'false'; - public const FAST_UPDATE = 'fastupdate'; - public const FILL_FACTOR = 'fillfactor'; + public const FASTUPDATE = 'fastupdate'; + public const FILLFACTOR = 'fillfactor'; public const FOREIGN_DATA_WRAPPER = 'foreign data wrapper'; public const FOREIGN_TABLE = 'foreign table'; public const FOR = 'for'; + public const FOR_ORDER_BY = 'for order by'; public const FOR_ROLE = 'for role'; + public const FOR_SEARCH = 'for search'; public const FROM_CURRENT = 'from current'; public const FUNCTION = 'function'; public const GRANT = 'grant'; @@ -77,6 +93,7 @@ class c_database_string { public const IF_EXISTS = 'if exists'; public const IMMUTABLE = 'immutable'; public const IN = 'in'; + public const IN_DATABASE = 'in database'; public const INOUT = 'inout'; public const IN_SCHEMA = 'in schema'; public const INHERIT = 'inherit'; @@ -84,11 +101,22 @@ class c_database_string { public const IS_TEMPLATE = 'is_template'; public const LANGUAGE = 'language'; public const LEAKPROOF = 'leakproof'; + public const LOGIN = 'login'; public const LOG_AUTOVACUUM_MIN_DURATION = 'log_autovacuum_min_duration'; public const MAIN = 'main'; public const MATERIALIZED_VIEW = 'materialized view'; + public const MAXVALUE = 'maxvalue'; + public const MINVALUE = 'minvalue'; public const N_DISTINCT = 'n_distinct'; public const N_DISTINCT_INHERITED = 'n_distinct_inherited'; + public const NO = 'no'; + public const NOBYPASSRLS = 'nobypassrls'; + public const NOCREATEDB = 'nocreatedb'; + public const NOCREATEROLE = 'nocreaterole'; + public const NOINHERIT = 'noinherit'; + public const NOLOGIN = 'nologin'; + public const NOREPLICATION = 'noreplication'; + public const NOSUPERUSER = 'nosuperuser'; public const NO_HANDLER = 'no handler'; public const NO_INHERIT = 'no inherit'; public const NO_VALIDATOR = 'no validator'; @@ -102,6 +130,7 @@ class c_database_string { public const ON_TABLES_TO = 'on tables to'; public const ON_TYPES = 'on types'; public const ONLY = 'only'; + public const OPERATOR = 'operator'; public const OPERATOR_CLASS = 'operator class'; public const OPERATOR_FAMILY = 'operator family'; public const OPTIONS = 'options'; @@ -112,16 +141,24 @@ class c_database_string { public const PAGES_PER_RANGE = 'pages_per_range'; public const PARALLEL = 'parallel'; public const PARALLEL_WORKERS = 'parallel_workers'; + public const PASSWORD = 'password'; + public const PASSWORD_ENCRYPTED = 'encypted password'; public const PLAIN = 'plain'; public const PROCEDURAL = 'procedural'; public const PUBLIC = 'public'; + public const PUBLISH = 'publish'; public const REFERENCES = 'references'; + public const REFRESH = 'refresh'; + public const REFRESH_PUBLICATION = 'refresh publication'; public const REFRESH_VERSION = 'refresh version'; public const RENAME_TO = 'rename to'; public const RENAME_COLUMN = 'rename column'; public const RENAME_CONSTRAINT = 'rename constraint'; + public const REPLICATION = 'replication'; public const RESET = 'reset'; public const RESET_ALL = 'reset all'; + public const RESET_PUBLICATION = 'reset publication'; + public const RESTART_WITH = 'restart with'; public const RESTRICT = 'restrict'; public const RESTRICTED = 'restricted'; public const RETURNS_NULL_ON_NULL_INPUT = 'returns null on null input'; @@ -137,15 +174,21 @@ class c_database_string { public const SERVER = 'server'; public const SET = 'set'; public const SET_DEFAULT = 'set default'; + public const SET_PUBLICATION = 'set publication'; public const SET_SCHEMA = 'set schema'; public const SET_STATISTICS = 'set statistics'; public const SET_STORAGE = 'set storage'; + public const SET_TABLE = 'set table'; public const SET_TABLESPACE = 'set tablespace'; public const SET_WITH_OIDS = 'set with oids'; public const SET_WITHOUT_CLUSTER = 'set without cluster'; public const SET_WITHOUT_OIDS = 'set without oids'; + public const SLOT_NAME = 'slot_name'; public const STABLE = 'stable'; + public const START_WITH = 'start with'; public const STRICT = 'strict'; + public const SUPERUSER = 'superuser'; + public const SYNCHRONOUS_COMMIT = 'synchronous_commit'; public const TABLE = 'table'; public const TEXT_SEARCH_CONFIGURATION = 'text search configuration'; public const TEXT_SEARCH_DICTIONARY = 'text search dictionary'; @@ -167,9 +210,12 @@ class c_database_string { public const USING = 'using'; public const VALIDATOR = 'validator'; public const VALIDATE_CONSTRAINT = 'validate constraint'; + public const VALIDUNTIL = 'validuntil'; public const VARIADIC = 'variadic'; + public const VERSION = 'version'; public const VOLATILE = 'volatile'; public const VIEW = 'view'; public const WITH = 'with'; + public const WITH_CHECK = 'with check'; public const WITH_GRANT_OPTION = 'with grant option'; } diff --git a/common/database/classes/database_truncate.php b/common/database/classes/database_truncate.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_truncate.php +++ b/common/database/classes/database_truncate.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_unlisten.php b/common/database/classes/database_unlisten.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_unlisten.php +++ b/common/database/classes/database_unlisten.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_update.php b/common/database/classes/database_update.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_update.php +++ b/common/database/classes/database_update.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_vacuum.php b/common/database/classes/database_vacuum.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_vacuum.php +++ b/common/database/classes/database_vacuum.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/classes/database_values.php b/common/database/classes/database_values.php index 54885a7..bf3857e 100644 --- a/common/database/classes/database_values.php +++ b/common/database/classes/database_values.php @@ -59,9 +59,15 @@ class c_database_alter_coalation extends c_database_query { * Implements do_build(). */ public function do_build() { - $this->value = NULL; + if (is_null($this->name)) { + return new c_base_return_false(); + } - // @todo + $value = $this->p_do_build_name(); + + $this->value = static::p_QUERY_COMMAND; + $this->value .= ' ' . $value; + unset($value); return new c_base_return_true(); } diff --git a/common/database/enumerations/database_operator_family.php b/common/database/enumerations/database_operator_family.php new file mode 100644 index 0000000..1973411 --- /dev/null +++ b/common/database/enumerations/database_operator_family.php @@ -0,0 +1,17 @@ +add_operator_family = NULL; + return new c_base_return_true(); + } + + if (!is_bool($add)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'add', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + switch ($type) { + case e_database_operator_family::OPERATOR: + case e_database_operator_family::FUNCTION: + break; + + default: + $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 (!is_int($strategy)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'strategy', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!($add && is_string($name)) || !(!$add && is_null($name))) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if ($add && $type === e_database_operator_family::OPERATOR) { + switch ($for_type) { + case e_database_operator_for::FOR_ORDER_BY: + case e_database_operator_for::FOR_SEARCH: + break; + + default: + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'for_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + } + + if (!is_string($left_type)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'left_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_string($right_type) && !(!$add && $type === e_database_operator_family::OPERATOR && is_null($right_type))) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'right_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_null($sort_family_name) && !is_string($sort_family_name)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'sort_family_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $value = [ + 'type' => $type, + 'strategy' => $strategy, + 'name' => NULL, + 'left_type' => NULL, + 'right_type' => NULL, + 'for_type' => NULL, + 'sort_family_name' => NULL, + ]; + + if ($add) { + $placeholder = $this->add_placeholder($name); + if ($placeholder->has_error()) { + unset($value); + return c_base_return_error::s_false($placeholder->get_error()); + } + + $value['name'] = $placeholder; + } + + $placeholder = $this->add_placeholder($left_type); + if ($placeholder->has_error()) { + unset($add_operator_family); + return c_base_return_error::s_false($placeholder->get_error()); + } + + $value['left_type'] = $placeholder; + + if (is_string($right_type)) { + $placeholder = $this->add_placeholder($right_type); + if ($placeholder->has_error()) { + unset($add_operator_family); + return c_base_return_error::s_false($placeholder->get_error()); + } + + $value['right_type'] = $placeholder; + } + + if ($add) { + $placeholder = $this->add_placeholder($for_type); + if ($placeholder->has_error()) { + unset($value); + return c_base_return_error::s_false($placeholder->get_error()); + } + + $value['for_type'] = $placeholder; + + if (is_string($sort_family_name)) { + $placeholder = $this->add_placeholder($sort_family_name); + if ($placeholder->has_error()) { + unset($value); + return c_base_return_error::s_false($placeholder->get_error()); + } + + $value['sort_family_name'] = $placeholder; + } + } + unset($placeholder); + + if (!is_array($this->add_operator_family)) { + $this->add_operator_family = [ + 'add' => TRUE, + 'values' => [], + ]; + } + + $this->add_operator_family['add'] = $add; + $this->add_operator_family['values'][] = $value; + unset($value); + + return new c_base_return_true(); + } + + /** + * Get the add/drop user settings. + * + * @param int|null $index + * (optional) Get the argument type array at the specified index. + * When NULL, all argument type are returned. + * + * @return c_base_return_array|c_base_return_null + * An array representing the add/drop operator settings at the $index. + * An array representing all add/drop operator settings when $index is NULL. + * NULL is returned if not set (add/drop operator is not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_add_operator_family($index = NULL) { + if (is_null($this->add_operator_family)) { + return new c_base_return_null(); + } + + if (is_null($index)) { + return c_base_return_array::s_new($this->add_operator_family); + } + else if (isset($this->add_operator_family['values'][$index]) && is_array($this->add_operator_family['values'][$index])) { + return c_base_return_array::s_new($this->add_operator_family['values'][$index]); + } + else { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'argument_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_null($error); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'add_operator_family', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_add_operator_family() { + $value = NULL; + + if ($this->add_operator_family['add']) { + $value = c_database_string::ADD; + } + else { + $value = c_database_string::DROP; + } + + $values = []; + foreach ($this->add_operator_family['values'] as $add_operator_family) { + if ($add_operator_family['for_type'] === e_database_operator_family::FUNCTION) { + $value .= ' ' . c_database_string::FUNCTION; + } + else if ($add_operator_family['for_type'] === e_database_operator_family::OPERATOR) { + $value .= ' ' . c_database_string::OPERATOR; + } + + $value .= ' ' . $add_operator_family['strategy']; + + if ($add_operator_family['add']) { + $value .= ' ' . $add_operator_family['name']; + } + + $value .= ' (' . $add_operator_family['left_type']; + if (is_string($add_operator_family['right_type'])) { + $value .= ' (' . $add_operator_family['right_type']; + } + $value .= ')'; + + if ($add_operator_family['add'] && $add_operator_family['type'] === e_database_operator_family::OPERATOR) { + if ($add_operator_family['for_type'] === e_database_operator_for::FOR_ORDER_BY) { + $value .= ' ' . c_database_string::FOR_ORDER_BY; + if (isset($add_operator_family['sort_family_name'])) { + $value .= ' ' . $add_operator_family['sort_family_name']; + } + } + else if ($add_operator_family['for_type'] === e_database_operator_for::FOR_SEARCH) { + $value .= ' ' . c_database_string::FOR_SEARCH; + } + } + + $values[] = $add_operator_family; + } + unset($add_operator_family); + + return $value . implode(', ', $values); + } +} diff --git a/common/database/traits/database_add_table.php b/common/database/traits/database_add_table.php new file mode 100644 index 0000000..58fcd34 --- /dev/null +++ b/common/database/traits/database_add_table.php @@ -0,0 +1,132 @@ +add_table = NULL; + return new c_base_return_true(); + } + + if (!is_string($name)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_null($only) && !is_bool($only)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'only', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_null($descendents) && !is_bool($descendents)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'descendents', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $placeholder = $this->add_placeholder($name); + if ($placeholder->has_error()) { + return c_base_return_error::s_false($placeholder->get_error()); + } + + if (!is_array($this->add_table)) { + $this->add_table = [ + 'only' => NULL, + 'values' => [], + ]; + } + + $this->add_table['values'][] = [ + 'name' => $placeholder, + 'descendents' => $descendents, + ]; + unset($placeholder); + + return new c_base_return_true(); + } + + /** + * Get the currently assigned add table settings. + * + * @param int|null $index + * (optional) Get the add table settings at the specified index. + * When NULL, all add table settings are returned. + * + * @return c_base_return_array|c_base_return_null + * An array containing the add table settings on success. + * NULL is returned if not set (add table not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_add_table() { + if (is_null($this->add_table)) { + return new c_base_return_null(); + } + + if (isset($this->add_table)) { + return c_base_return_array::s_new($this->add_table); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'add_table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_add_table() { + $value = c_database_string::ADD_TABLE; + + if ($this->add_table['only']) { + $value .= ' ' . c_database_string::ONLY; + } + + $values = []; + foreach ($this->add_table['values'] as $add_value) { + $name = $add_value['name']; + if ($add_value['descendents']) { + $name .= ' *'; + } + $values[] = $name; + } + unset($add_value); + unset($name); + + return $value . ' ' . implode(', ', $values); + } +} diff --git a/common/database/traits/database_add_user.php b/common/database/traits/database_add_user.php index 061cb31..d230563 100644 --- a/common/database/traits/database_add_user.php +++ b/common/database/traits/database_add_user.php @@ -23,7 +23,7 @@ trait t_database_add_user { /** * Set the add user or drop user. * - * @param string|int|bool|null $role_type + * @param string|int|bool|null $name * The user name (role name) to use. * Set to TRUE to toggle to ADD USER (default). * Set to FALSE to toggle to DROP USER. diff --git a/common/database/traits/database_argument_type.php b/common/database/traits/database_argument_type.php index 177c674..87214bf 100644 --- a/common/database/traits/database_argument_type.php +++ b/common/database/traits/database_argument_type.php @@ -107,7 +107,7 @@ trait t_database_argument_type { return new c_base_return_null(); } - if (is_null($this->argument_type['type'])) { + if (is_null($index)) { return c_base_return_array::s_new($this->argument_type); } else if (isset($this->argument_type[$index]) && is_array($this->argument_type[$index])) { diff --git a/common/database/traits/database_as_data_type.php b/common/database/traits/database_as_data_type.php new file mode 100644 index 0000000..16abfba --- /dev/null +++ b/common/database/traits/database_as_data_type.php @@ -0,0 +1,85 @@ +as_data_type = NULL; + return new c_base_return_true(); + } + + if (is_string($type)) { + $placeholder = $this->add_placeholder($type); + if ($placeholder->has_error()) { + return c_base_return_error::s_false($placeholder->get_error()); + } + + $this->as_data_type = $placeholder; + unset($placeholder); + + return new c_base_return_true(); + } + + $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); + } + + /** + * Get the currently assigned data type. + * + * @return i_database_query_placeholder|c_base_return_null + * A data type query placeholder on success. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_as_data_type() { + if (is_null($this->as_data_type)) { + return new c_base_return_null(); + } + + if (isset($this->as_data_type)) { + return clone($this->as_data_type); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'as_data_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_as_data_type() { + return c_database_string::AS . ' ' . $this->as_data_type; + } +} diff --git a/common/database/traits/database_cache.php b/common/database/traits/database_cache.php new file mode 100644 index 0000000..14a1d4f --- /dev/null +++ b/common/database/traits/database_cache.php @@ -0,0 +1,79 @@ +cache = NULL; + return new c_base_return_true(); + } + + if (is_int($sequence) && $sequence > 0) { + $this->cache = $sequence; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'sequence', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned cache sequence number. + * + * @return c_base_return_int|c_base_return_null + * A cache sequence number. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_cache() { + if (is_null($this->cache)) { + return new c_base_return_null(); + } + + if (isset($this->cache)) { + return c_base_return_int::s_new($this->cache); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'cache', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_cache() { + return c_database_string::CACHE . ' ' . $this->cache; + } +} diff --git a/common/database/traits/database_cluster_on.php b/common/database/traits/database_cluster_on.php index e1b4c2e..2a0ee79 100644 --- a/common/database/traits/database_cluster_on.php +++ b/common/database/traits/database_cluster_on.php @@ -11,13 +11,13 @@ require_once('common/base/classes/base_error.php'); require_once('common/base/classes/base_return.php'); /** - * Provide the sql NAME functionality. + * Provide the sql CLUSTER ON functionality. */ trait t_database_cluster_on { protected $cluster_on; /** - * Set the OID settings. + * Set the CLUSTER ON settings. * * @param string|null $index_name * The index name to use. @@ -50,7 +50,7 @@ trait t_database_cluster_on { } /** - * Get the currently assigned index name. + * Get the currently assigned cluster on setting. * * @return i_database_query_placeholder|c_base_return_null * A index name query placeholder on success. @@ -80,6 +80,6 @@ trait t_database_cluster_on { * NULL is returned if there is nothing to process or there is an error. */ protected function p_do_build_cluster_on() { - return strval($this->cluster_on); + return c_database_string::CLUSTER_ON . ' ' . strval($this->cluster_on); } } diff --git a/common/database/traits/database_connection.php b/common/database/traits/database_connection.php new file mode 100644 index 0000000..e77f297 --- /dev/null +++ b/common/database/traits/database_connection.php @@ -0,0 +1,85 @@ +connection = NULL; + return new c_base_return_true(); + } + + if (is_string($value)) { + $placeholder = $this->add_placeholder($value); + if ($placeholder->has_error()) { + return c_base_return_error::s_false($placeholder->get_error()); + } + + $this->connection = $placeholder; + unset($placeholder); + + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned on connection information settings. + * + * @return i_database_query_placeholder|c_base_return_null + * A connection information query placeholder on success. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_connection() { + if (is_null($this->connection)) { + return new c_base_return_null(); + } + + if (isset($this->connection)) { + return clone($this->connection); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'connection', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_connection() { + return c_database_string::CONNECTION . ' ' . strval($this->connection); + } +} diff --git a/common/database/traits/database_cycle.php b/common/database/traits/database_cycle.php new file mode 100644 index 0000000..d32376c --- /dev/null +++ b/common/database/traits/database_cycle.php @@ -0,0 +1,83 @@ +cycle = NULL; + return new c_base_return_true(); + } + + if (is_bool($cycle)) { + $this->cycle = $cycle; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'cycle', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned data type. + * + * @return c_base_return_bool|c_base_return_null + * A boolean with TRUE repesenting CYCLE and FALSE representing NO CYCLE. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_cycle() { + if (is_null($this->cycle)) { + return new c_base_return_null(); + } + + if (is_bool($this->cycle)) { + return c_base_return_bool::s_new($this->cycle); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'cycle', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_cycle() { + if ($this->cycle) { + return c_database_string::CYCLE; + } + + return c_database_string::NO . ' ' . c_database_string::CYCLE; + } +} diff --git a/common/database/traits/database_disable.php b/common/database/traits/database_disable.php new file mode 100644 index 0000000..affa0b1 --- /dev/null +++ b/common/database/traits/database_disable.php @@ -0,0 +1,82 @@ +disable = NULL; + return new c_base_return_true(); + } + + if (is_bool($disable)) { + $this->disable = $disable; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'disable', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned data type. + * + * @return c_base_return_bool|c_base_return_null + * A boolean with TRUE repesenting DISABLE. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_disable() { + if (is_null($this->disable)) { + return new c_base_return_null(); + } + + if (is_bool($this->disable)) { + return c_base_return_bool::s_new($this->disable); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'disable', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_disable() { + if ($this->disable) { + return c_database_string::DISABLE; + } + + return NULL; + } +} diff --git a/common/database/traits/database_drop_table.php b/common/database/traits/database_drop_table.php new file mode 100644 index 0000000..5ac08ea --- /dev/null +++ b/common/database/traits/database_drop_table.php @@ -0,0 +1,132 @@ +drop_value = NULL; + return new c_base_return_true(); + } + + if (!is_string($name)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_null($only) && !is_bool($only)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'only', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_null($descendents) && !is_bool($descendents)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'descendents', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $placeholder = $this->add_placeholder($name); + if ($placeholder->has_error()) { + return c_base_return_error::s_false($placeholder->get_error()); + } + + if (!is_array($this->drop_value)) { + $this->drop_value = [ + 'only' => NULL, + 'values' => [], + ]; + } + + $this->drop_value['values'][] = [ + 'name' => $placeholder, + 'descendents' => $descendents, + ]; + unset($placeholder); + + return new c_base_return_true(); + } + + /** + * Get the currently assigned add table settings. + * + * @param int|null $index + * (optional) Get the add table settings at the specified index. + * When NULL, all add table settings are returned. + * + * @return c_base_return_array|c_base_return_null + * An array containing the add table settings on success. + * NULL is returned if not set (add table not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_drop_value() { + if (is_null($this->drop_value)) { + return new c_base_return_null(); + } + + if (isset($this->drop_value)) { + return c_base_return_array::s_new($this->drop_value); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'drop_value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_drop_value() { + $value = c_database_string::DROP_TABLE; + + if ($this->drop_value['only']) { + $value .= ' ' . c_database_string::ONLY; + } + + $values = []; + foreach ($this->drop_value['values'] as $drop_value) { + $name = $drop_value['name']; + if ($drop_value['descendents']) { + $name .= ' *'; + } + $values[] = $name; + } + unset($drop_value); + unset($name); + + return $value . ' ' . implode(', ', $values); + } +} diff --git a/common/database/traits/database_enable.php b/common/database/traits/database_enable.php new file mode 100644 index 0000000..a446aff --- /dev/null +++ b/common/database/traits/database_enable.php @@ -0,0 +1,82 @@ +enable = NULL; + return new c_base_return_true(); + } + + if (is_bool($enable)) { + $this->enable = $enable; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'enable', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned data type. + * + * @return c_base_return_bool|c_base_return_null + * A boolean with TRUE repesenting ENABLE. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_enable() { + if (is_null($this->enable)) { + return new c_base_return_null(); + } + + if (is_bool($this->enable)) { + return c_base_return_bool::s_new($this->enable); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'enable', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_enable() { + if ($this->enable) { + return c_database_string::ENABLE; + } + + return NULL; + } +} diff --git a/common/database/traits/database_in_database.php b/common/database/traits/database_in_database.php new file mode 100644 index 0000000..d1757ee --- /dev/null +++ b/common/database/traits/database_in_database.php @@ -0,0 +1,85 @@ +in_database = NULL; + return new c_base_return_true(); + } + + if (is_string($name)) { + $placeholder = $this->add_placeholder($name); + if ($placeholder->has_error()) { + return c_base_return_error::s_false($placeholder->get_error()); + } + + $this->in_database = $placeholder; + unset($placeholder); + + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned database name. + * + * @return i_database_query_placeholder|c_base_return_null + * A database name query placeholder on success. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_in_database() { + if (is_null($this->in_database)) { + return new c_base_return_null(); + } + + if (isset($this->in_database)) { + return clone($this->in_database); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'in_database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_in_database() { + return c_database_string::IN_DATABASE . ' ' . $this->in_database; + } +} diff --git a/common/database/traits/database_increment_by.php b/common/database/traits/database_increment_by.php new file mode 100644 index 0000000..2ab5a87 --- /dev/null +++ b/common/database/traits/database_increment_by.php @@ -0,0 +1,78 @@ +increment_by = NULL; + return new c_base_return_true(); + } + + if (is_int($by)) { + $this->increment_by = $by; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'by', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned increment by value. + * + * @return c_base_return_int|c_base_return_null + * An increment by number. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_increment_by() { + if (is_null($this->increment_by)) { + return new c_base_return_null(); + } + + if (is_int($this->increment_by)) { + return c_base_return_int::s_new($this->increment_by); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'increment_by', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_increment_by() { + return c_database_string::INCREMENT_BY . ' ' . $this->increment_by; + } +} diff --git a/common/database/traits/database_max_value.php b/common/database/traits/database_max_value.php new file mode 100644 index 0000000..ac43fed --- /dev/null +++ b/common/database/traits/database_max_value.php @@ -0,0 +1,87 @@ +max_value = NULL; + return new c_base_return_true(); + } + + if (is_int($value) || $value === FALSE) { + $this->max_value = $value; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned max value. + * + * @return c_base_return_string|c_base_return_bool|c_base_return_null + * A number representing the max value. + * FALSE for no max value. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_max_value() { + if (is_null($this->max_value)) { + return new c_base_return_null(); + } + + if (is_int($this->max_value)) { + return c_base_return_int::s_new($this->max_value); + } + else if ($this->max_value === FALSE) { + return c_base_return_bool::s_new($this->max_value); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'max_value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_max_value() { + if ($this->max_value === FALSE) { + return c_database_string::NO . ' ' . c_database_string::MAXVALUE; + } + + return c_database_string::MAXVALUE . ' ' . $this->max_value; + } +} diff --git a/common/database/traits/database_min_value.php b/common/database/traits/database_min_value.php new file mode 100644 index 0000000..f2045cb --- /dev/null +++ b/common/database/traits/database_min_value.php @@ -0,0 +1,87 @@ +min_value = NULL; + return new c_base_return_true(); + } + + if (is_int($value) || $value === FALSE) { + $this->min_value = $value; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned min value. + * + * @return c_base_return_string|c_base_return_bool|c_base_return_null + * A number representing the min value. + * FALSE for no min value. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_min_value() { + if (is_null($this->min_value)) { + return new c_base_return_null(); + } + + if (is_int($this->min_value)) { + return c_base_return_int::s_new($this->min_value); + } + else if ($this->min_value === FALSE) { + return c_base_return_bool::s_new($this->min_value); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'min_value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_min_value() { + if ($this->min_value === FALSE) { + return c_database_string::NO . ' ' . c_database_string::MINVALUE; + } + + return c_database_string::MINVALUE . ' ' . $this->min_value; + } +} diff --git a/common/database/traits/database_oid.php b/common/database/traits/database_oid.php index a98db9e..63a9e9c 100644 --- a/common/database/traits/database_oid.php +++ b/common/database/traits/database_oid.php @@ -11,81 +11,7 @@ require_once('common/base/classes/base_error.php'); require_once('common/base/classes/base_return.php'); /** - * Provide the sql NAME functionality. - */ -trait t_database_oid { - protected $oid; - - /** - * Set the OID settings. - * - * @param string|null $oid - * The oid to use. - * Set to NULL to disable. - * - * @return c_base_return_status - * TRUE on success, FALSE otherwise. - * FALSE with the error bit set is returned on error. - */ - public function set_oid($oid) { - if (is_null($oid)) { - $this->oid = NULL; - return new c_base_return_true(); - } - - if (is_string($oid)) { - $placeholder = $this->add_placeholder($oid); - if ($placeholder->has_error()) { - return c_base_return_error::s_false($placeholder->get_error()); - } - - $this->oid = $placeholder; - unset($placeholder); - - return new c_base_return_true(); - } - - $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'oid', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); - return c_base_return_error::s_false($error); - } - - /** - * Get the currently assigned oid. - * - * @return i_database_query_placeholder|c_base_return_null - * A oid query placeholder on success. - * NULL is returned if not set. - * NULL with the error bit set is returned on error. - */ - public function get_oid() { - if (is_null($this->oid)) { - return new c_base_return_null(); - } - - if (isset($this->oid)) { - return clone($this->oid); - } - - $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'oid', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); - return c_base_return_error::s_null($error); - } - - /** - * Perform the common build process for this trait. - * - * As an internal trait method, the caller is expected to perform any appropriate validation. - * - * @return string|null - * 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_oid() { - return strval($this->oid); - } -} - -/** - * Provide the sql NAME functionality. + * Provide the sql OID functionality. */ trait t_database_oid { protected $oid; diff --git a/common/database/traits/database_using.php b/common/database/traits/database_on_table.php similarity index 60% rename from common/database/traits/database_using.php rename to common/database/traits/database_on_table.php index a77b254..cbaa659 100644 --- a/common/database/traits/database_using.php +++ b/common/database/traits/database_on_table.php @@ -11,62 +11,62 @@ require_once('common/base/classes/base_error.php'); require_once('common/base/classes/base_return.php'); /** - * Provide the sql USING functionality. + * Provide the sql ON TABLE functionality. */ -trait t_database_using { - protected $using; +trait t_database_on_table { + protected $on_table; /** - * Set the USING settings. + * Set the ON TABLE settings. * - * @param string|null $using - * The using to use. + * @param string|null $name + * The table name to use. * Set to NULL to disable. * * @return c_base_return_status * TRUE on success, FALSE otherwise. * FALSE with the error bit set is returned on error. */ - public function set_using($using) { - if (is_null($using)) { - $this->using = NULL; + public function set_on_table($name) { + if (is_null($name)) { + $this->on_table = NULL; return new c_base_return_true(); } - if (is_string($using)) { - $placeholder = $this->add_placeholder($using); + if (is_string($name)) { + $placeholder = $this->add_placeholder($name); if ($placeholder->has_error()) { return c_base_return_error::s_false($placeholder->get_error()); } - $this->using = $placeholder; + $this->on_table = $placeholder; unset($placeholder); return new c_base_return_true(); } - $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'using', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); return c_base_return_error::s_false($error); } /** - * Get the currently assigned using. + * Get the currently assigned on table settings. * * @return i_database_query_placeholder|c_base_return_null - * A using query placeholder on success. + * A name query placeholder on success. * NULL is returned if not set. * NULL with the error bit set is returned on error. */ - public function get_using() { - if (is_null($this->using)) { + public function get_on_table() { + if (is_null($this->on_table)) { return new c_base_return_null(); } - if (isset($this->using)) { - return clone($this->using); + if (isset($this->on_table)) { + return clone($this->on_table); } - $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'using', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'on_table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); return c_base_return_error::s_null($error); } @@ -79,7 +79,7 @@ trait t_database_using { * 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_using() { - return strval($this->using); + protected function p_do_build_on_table() { + return strval($this->on_table); } } diff --git a/common/database/traits/database_owned_by.php b/common/database/traits/database_owned_by.php index 809a4ad..34e96e4 100644 --- a/common/database/traits/database_owned_by.php +++ b/common/database/traits/database_owned_by.php @@ -37,7 +37,7 @@ trait t_database_owned_by { } if (is_int($owned_by)) { - if ($owned_by === e_database_user::ALL) { + if ($owned_by === e_database_user::ALL || $owned_by === e_database_user::NONE) { $this->owned_by = e_database_user::ALL; return new c_base_return_true(); @@ -79,7 +79,7 @@ trait t_database_owned_by { } if (is_null($index)) { - if ($this->owned_by === e_database_user::ALL) { + if ($this->owned_by === e_database_user::ALL || $this->owned_by === e_database_user::NONE) { return c_base_return_array::s_new([$this->owned_by]); } else if (is_array($this->owned_by)) { @@ -115,15 +115,18 @@ trait t_database_owned_by { * NULL is returned if there is nothing to process or there is an error. */ protected function p_do_build_owned_by() { - $owned_by = c_database_string::OWNED_BY . ' '; + $value = c_database_string::OWNED_BY . ' '; if ($this->owned_by === e_database_user::ALL) { - $owned_by .= c_database_string::ALL; + $value .= c_database_string::ALL; + } + else if ($this->owned_by === e_database_user::NONE) { + $value .= c_database_string::NONE; } else { - $owned_by .= implode(', ', $this->owned_by); + $value .= implode(', ', $this->owned_by); } - return $owned_by; + return $value; } } diff --git a/common/database/traits/database_refresh_publication.php b/common/database/traits/database_refresh_publication.php new file mode 100644 index 0000000..53c1dfe --- /dev/null +++ b/common/database/traits/database_refresh_publication.php @@ -0,0 +1,79 @@ +refresh_publication = NULL; + return new c_base_return_true(); + } + + if (!is_bool($refresh)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => '$refresh', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->refresh_publication = $refresh; + return new c_base_return_true(); + } + + /** + * Get the currently assigned REFRESH PUBLICATION setting. + * + * @return c_base_return_bool|c_base_return_null + * A boolean representing whether or not refresh publication is to be used. + * NULL is returned if not set (refresh publication not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_refresh_publication($index = NULL) { + if (is_null($this->refresh_publication)) { + return new c_base_return_null(); + } + + return c_base_return_bool::s_new($this->refresh_publication); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_refresh_publication() { + if ($this->refresh_publication) { + return c_database_string::REFRESH_PUBLICATION; + } + + return NULL; + } +} diff --git a/common/database/traits/database_reset_storage_parameter.php b/common/database/traits/database_reset_storage_parameter.php index 9144a24..142a66b 100644 --- a/common/database/traits/database_reset_storage_parameter.php +++ b/common/database/traits/database_reset_storage_parameter.php @@ -41,8 +41,8 @@ trait t_database_reset_storage_parameter { switch ($storage_parameter) { case e_database_storage_parameter::AUTOSUMMARIZE: case e_database_storage_parameter::BUFFERING: - case e_database_storage_parameter::FAST_UPDATE: - case e_database_storage_parameter::FILL_FACTOR: + case e_database_storage_parameter::FASTUPDATE: + case e_database_storage_parameter::FILLFACTOR: case e_database_storage_parameter::GIN_PENDING_LIST_LIMIT: case e_database_storage_parameter::PAGES_PER_RANGE: break; @@ -112,11 +112,11 @@ trait t_database_reset_storage_parameter { else if ($storage_parameter === e_database_storage_parameter::BUFFERING) { $values[] = c_database_string::BUFFERING; } - else if ($storage_parameter === e_database_storage_parameter::FAST_UPDATE) { - $values[] = c_database_string::FAST_UPDATE; + else if ($storage_parameter === e_database_storage_parameter::FASTUPDATE) { + $values[] = c_database_string::FASTUPDATE; } - else if ($storage_parameter === e_database_storage_parameter::FILL_FACTOR) { - $values[] = c_database_string::FILL_FACTOR; + else if ($storage_parameter === e_database_storage_parameter::FILLFACTOR) { + $values[] = c_database_string::FILLFACTOR; } else if ($storage_parameter === e_database_storage_parameter::GIN_PENDING_LIST_LIMIT) { $values[] = c_database_string::GIN_PENDING_LIST_LIMIT; @@ -127,6 +127,6 @@ trait t_database_reset_storage_parameter { } unset($storage_parameter); - return c_database_string::RESET . ' ' . implode(', ', $values); + return c_database_string::RESET . ' (' . implode(', ', $values) . ')'; } } diff --git a/common/database/traits/database_restart_with.php b/common/database/traits/database_restart_with.php new file mode 100644 index 0000000..c4f162d --- /dev/null +++ b/common/database/traits/database_restart_with.php @@ -0,0 +1,83 @@ +restart_with = NULL; + return new c_base_return_true(); + } + + if (is_int($value) || $value === FALSE) { + $this->restart_with = $value; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned restart with value. + * + * @return c_base_return_int|c_base_return_bool|c_base_return_null + * A number representing the start with value. + * FALSE is returned when default START WITH value is to be used. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_restart_with() { + if (is_null($this->restart_with)) { + return new c_base_return_null(); + } + + if (is_int($this->restart_with)) { + return c_base_return_int::s_new($this->restart_with); + } + else if (is_bool($this->restart_with)) { + return c_base_return_bool::s_new($this->restart_with); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'restart_with', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_restart_with() { + return c_database_string::RESTART_WITH . ' ' . $this->restart_with; + } +} diff --git a/common/database/traits/database_role_specification.php b/common/database/traits/database_role_specification.php index 9fab202..d54d9da 100644 --- a/common/database/traits/database_role_specification.php +++ b/common/database/traits/database_role_specification.php @@ -25,7 +25,7 @@ trait t_database_role_specification { * * @param int|string|null $name * A string representing the role name to use. - * May be an integer of either e_database_role::CURRENT or e_database_role::SESSION. + * May be an integer of from e_database_role. * Set to NULL to disable. * When NULL, this will remove all values. * @@ -48,7 +48,7 @@ trait t_database_role_specification { $this->role_specification = $placeholder; unset($placeholder); } - else if ($name !== e_database_role::CURRENT && $name !== e_database_role::SESSION) { + else if ($name !== e_database_role::ALL && $name !== e_database_role::CURRENT && $name !== e_database_role::SESSION) { $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); return c_base_return_error::s_false($error); @@ -62,7 +62,7 @@ trait t_database_role_specification { * Get the role specification. * * @return c_base_return_int|i_database_query_placeholder|c_base_return_null - * A role name query placeholder or an integer representing either e_database_role::CURRENT or e_database_role::SESSION on success. + * A role name query placeholder or an integer from e_database_role. * NULL is returned if not set. * NULL with the error bit set is returned on error. */ @@ -71,7 +71,7 @@ trait t_database_role_specification { return new c_base_return_null(); } - if ($this->role_specification === e_database_role::CURRENT || $this->role_specification === e_database_role::SESSION) { + if ($this->role_specification === e_database_role::ALL || $this->role_specification === e_database_role::CURRENT || $this->role_specification === e_database_role::SESSION) { return c_base_return_int::s_new($this->role_specification); } else if (isset($this->role_specification)) { @@ -94,7 +94,10 @@ trait t_database_role_specification { protected function p_do_build_role_specification() { $value = NULL; if (is_string($this->role_specification)) { - $value = $this->role_specification; + $value = strval($this->role_specification); + } + else if ($this->role_specification === e_database_role::ALL) { + $value = c_database_string::ALL; } else if ($this->role_specification === e_database_role::CURRENT) { $value = c_database_string::CURRENT; @@ -103,6 +106,6 @@ trait t_database_role_specification { $value = c_database_string::SESSION; } - return strval($value); + return $value; } } diff --git a/common/database/traits/database_set_publication_name.php b/common/database/traits/database_set_publication_name.php new file mode 100644 index 0000000..2a82eb2 --- /dev/null +++ b/common/database/traits/database_set_publication_name.php @@ -0,0 +1,98 @@ +set_publication_name = NULL; + return new c_base_return_true(); + } + + if (!is_string($name)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->set_publication_name)) { + $this->set_publication_name = []; + } + + $this->set_publication_name[] = $name; + return new c_base_return_true(); + } + + /** + * Get the currently assigned SET PUBLICATION name at the specified index. + * + * @param int|null $index + * (optional) Get the publication name at the specified index. + * When NULL, all publication names are returned. + * + * @return c_base_return_array|c_base_return_string|c_base_return_null + * An array of publication names or a string representing the publication name at $index.. + * NULL is returned if not set (publication name not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_set_publication_name($index = NULL) { + if (is_null($this->set_publication_name)) { + return new c_base_return_null(); + } + + if (is_null($index)) { + if (is_array($this->set_publication_name)) { + return c_base_return_array::s_new($this->set_publication_name); + } + } + else { + if (is_int($index) && array_key_exists($index, $this->set_publication_name)) { + return c_base_return_string::s_new($this->set_publication_name[$index]); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_publication_name[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_publication_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_publication_name() { + return c_database_string::SET_PUBLICATION . ' ' . implode(', ', $this->set_publication_name); + } +} diff --git a/common/database/traits/database_set_publication_parameter.php b/common/database/traits/database_set_publication_parameter.php new file mode 100644 index 0000000..cbfa271 --- /dev/null +++ b/common/database/traits/database_set_publication_parameter.php @@ -0,0 +1,148 @@ +set_publication_parameter = NULL; + return new c_base_return_true(); + } + + switch ($parameter) { + case e_database_publication_parameter::PUBLISH: + break; + default: + $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); + } + + switch ($value) { + case e_database_publication_value::DELETE: + case e_database_publication_value::INSERT: + case e_database_publication_value::UPDATE: + break; + default: + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->set_publication_parameter)) { + $this->set_publication_parameter = []; + } + + $this->set_publication_parameter[] = [ + 'type' => $parameter, + 'value' => $value, + ]; + + return new c_base_return_true(); + } + + /** + * Get the currently assigned SET publication parameter at the specified index. + * + * @param int|null $index + * (optional) Get the publication parameter type at the specified index. + * When NULL, all publication parameter types are returned. + * + * @return c_base_return_array|c_base_return_null + * An array containing the set publication parameter settings on success. + * NULL is returned if not set (publication parameter not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_set_publication_parameter($index = NULL) { + if (is_null($this->set_publication_parameter)) { + return new c_base_return_null(); + } + + if (is_null($index)) { + if (is_array($this->set_publication_parameter)) { + return c_base_return_array::s_new($this->set_publication_parameter); + } + } + else { + if (is_int($index) && array_key_exists($index, $this->set_publication_parameter)) { + return c_base_return_array::s_new($this->set_publication_parameter[$index]); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_publication_parameter[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_publication_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_publication_parameter() { + $values = []; + foreach ($this->set_publication_parameter as $parameter => $value) { + if ($parameter === e_database_publication_parameter::PUBLISH) { + $parameter_value = c_database_string::PUBLISH . ' = '; + + if ($value === e_database_publication_value::DELETE) { + $parameter_value .= c_database_string::DELETE; + } + else if ($value === e_database_publication_value::INSERT) { + $parameter_value .= c_database_string::INSERT; + } + else if ($value === e_database_publication_value::UPDATE) { + $parameter_value .= c_database_string::UPDATE; + } + else { + continue; + } + + $values[] = $parameter_value; + } + } + unset($parameter_value); + unset($parameter); + unset($value); + + return c_database_string::SET . ' (' . implode(', ', $values) . ')'; + } +} diff --git a/common/database/traits/database_set_schema.php b/common/database/traits/database_set_schema.php index 670dc23..99431cb 100644 --- a/common/database/traits/database_set_schema.php +++ b/common/database/traits/database_set_schema.php @@ -22,7 +22,7 @@ trait t_database_set_schema { * Set the RENAME TO settings. * * @param string|null $set_schema - * The name to rename to. + * The schema name. * Set to NULL to disable. * * @return c_base_return_status @@ -50,7 +50,7 @@ trait t_database_set_schema { * Get the currently assigned schema name to set to. * * @return i_database_query_placeholder|c_base_return_null - * A schema name on success. + * A schema name query placeholder on success. * NULL is returned if not set (set schema is not to be used). * NULL with the error bit set is returned on error. */ diff --git a/common/database/traits/database_set_storage_parameter.php b/common/database/traits/database_set_storage_parameter.php index 467bf3f..3addcda 100644 --- a/common/database/traits/database_set_storage_parameter.php +++ b/common/database/traits/database_set_storage_parameter.php @@ -15,7 +15,7 @@ require_once('common/database/enumerations/database_index_storage_parameter.php' require_once('common/database/classes/database_string.php'); /** - * Provide the sql SET functionality. + * Provide the sql SET storage parameter functionality. */ trait t_database_set_storage_parameter { protected $set_storage_parameter; @@ -23,7 +23,7 @@ trait t_database_set_storage_parameter { /** * Set the SET index (storage_parameter ...) settings. * - * @param int|null $storage_parameter + * @param int|null $parameter * The storage parameter code to assign. * Should be one of: e_database_storage_parameter. * Set to NULL to disable. @@ -36,22 +36,22 @@ trait t_database_set_storage_parameter { * TRUE on success, FALSE otherwise. * FALSE with the error bit set is returned on error. */ - public function set_storage_parameter($storage_parameter, $value = NULL) { - if (is_null($storage_parameter)) { + public function set_set_storage_parameter($parameter, $value = NULL) { + if (is_null($parameter)) { $this->set_storage_parameter = NULL; return new c_base_return_true(); } - switch ($storage_parameter) { + switch ($parameter) { case e_database_storage_parameter::AUTOSUMMARIZE: case e_database_storage_parameter::BUFFERING: - case e_database_storage_parameter::FAST_UPDATE: - case e_database_storage_parameter::FILL_FACTOR: + case e_database_storage_parameter::FASTUPDATE: + case e_database_storage_parameter::FILLFACTOR: case e_database_storage_parameter::GIN_PENDING_LIST_LIMIT: case e_database_storage_parameter::PAGES_PER_RANGE: break; default: - $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'storage_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + $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); } @@ -70,7 +70,7 @@ trait t_database_set_storage_parameter { } $this->set_storage_parameter[] = [ - 'type' => $storage_parameter, + 'type' => $parameter, 'value' => $placeholder, ]; unset($placeholder); @@ -124,29 +124,29 @@ trait t_database_set_storage_parameter { */ protected function p_do_build_set_storage_parameter() { $values = []; - foreach ($this->set_storage_parameter as $storage_parameter => $value) { - if ($storage_parameter === e_database_storage_parameter::AUTOSUMMARIZE) { + foreach ($this->set_storage_parameter as $parameter => $value) { + if ($parameter === e_database_storage_parameter::AUTOSUMMARIZE) { $values[] = c_database_string::AUTOSUMMARIZE . ' = ' . $value; } - else if ($storage_parameter === e_database_storage_parameter::BUFFERING) { + else if ($parameter === e_database_storage_parameter::BUFFERING) { $values[] = c_database_string::BUFFERING . ' = ' . $value; } - else if ($storage_parameter === e_database_storage_parameter::FAST_UPDATE) { - $values[] = c_database_string::FAST_UPDATE . ' = ' . $value; + else if ($parameter === e_database_storage_parameter::FASTUPDATE) { + $values[] = c_database_string::FASTUPDATE . ' = ' . $value; } - else if ($storage_parameter === e_database_storage_parameter::FILL_FACTOR) { - $values[] = c_database_string::FILL_FACTOR . ' = ' . $value; + else if ($parameter === e_database_storage_parameter::FILLFACTOR) { + $values[] = c_database_string::FILLFACTOR . ' = ' . $value; } - else if ($storage_parameter === e_database_storage_parameter::GIN_PENDING_LIST_LIMIT) { + else if ($parameter === e_database_storage_parameter::GIN_PENDING_LIST_LIMIT) { $values[] = c_database_string::GIN_PENDING_LIST_LIMIT . ' = ' . $value; } - else if ($storage_parameter === e_database_storage_parameter::PAGES_PER_RANGE) { + else if ($parameter === e_database_storage_parameter::PAGES_PER_RANGE) { $values[] = c_database_string::PAGES_PER_RANGE . ' = ' . $value ; } } - unset($storage_parameter); + unset($parameter); unset($value); - return c_database_string::SET . ' ' . implode(', ', $values); + return c_database_string::SET . ' (' . implode(', ', $values) . ')'; } } diff --git a/common/database/traits/database_set_table.php b/common/database/traits/database_set_table.php new file mode 100644 index 0000000..330a312 --- /dev/null +++ b/common/database/traits/database_set_table.php @@ -0,0 +1,132 @@ +set_table = NULL; + return new c_base_return_true(); + } + + if (!is_string($name)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_null($only) && !is_bool($only)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'only', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_null($descendents) && !is_bool($descendents)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'descendents', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $placeholder = $this->add_placeholder($name); + if ($placeholder->has_error()) { + return c_base_return_error::s_false($placeholder->get_error()); + } + + if (!is_array($this->set_table)) { + $this->set_table = [ + 'only' => NULL, + 'values' => [], + ]; + } + + $this->set_table['values'][] = [ + 'name' => $placeholder, + 'descendents' => $descendents, + ]; + unset($placeholder); + + return new c_base_return_true(); + } + + /** + * Get the currently assigned add table settings. + * + * @param int|null $index + * (optional) Get the add table settings at the specified index. + * When NULL, all add table settings are returned. + * + * @return c_base_return_array|c_base_return_null + * An array containing the add table settings on success. + * NULL is returned if not set (add table not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_set_table() { + if (is_null($this->set_table)) { + return new c_base_return_null(); + } + + if (isset($this->set_table)) { + return c_base_return_array::s_new($this->set_table); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_table', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_table() { + $value = c_database_string::SET_TABLE; + + if ($this->set_table['only']) { + $value .= ' ' . c_database_string::ONLY; + } + + $values = []; + foreach ($this->set_table['values'] as $set_value) { + $name = $set_value['name']; + if ($set_value['descendents']) { + $name .= ' *'; + } + $values[] = $name; + } + unset($set_value); + unset($name); + + return $value . ' ' . implode(', ', $values); + } +} diff --git a/common/database/traits/database_start_with.php b/common/database/traits/database_start_with.php new file mode 100644 index 0000000..013d098 --- /dev/null +++ b/common/database/traits/database_start_with.php @@ -0,0 +1,78 @@ +start_with = NULL; + return new c_base_return_true(); + } + + if (is_int($value)) { + $this->start_with = $value; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned start with value. + * + * @return c_base_return_string|c_base_return_null + * A number representing the start with value. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_start_with() { + if (is_null($this->start_with)) { + return new c_base_return_null(); + } + + if (is_int($this->start_with)) { + return c_base_return_int::s_new($this->start_with); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'start_with', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_start_with() { + return c_database_string::START_WITH . ' ' . $this->start_with; + } +} diff --git a/common/database/traits/database_using_expression.php b/common/database/traits/database_using_expression.php new file mode 100644 index 0000000..383c519 --- /dev/null +++ b/common/database/traits/database_using_expression.php @@ -0,0 +1,80 @@ +using_expression = NULL; + return new c_base_return_true(); + } + + if (is_string($sql_expression)) { + $this->using_expression = $sql_expression; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'sql_expression', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned USING expression settings. + * + * @return c_base_return_string|c_base_return_null + * A name query placeholder on success. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_using_expression() { + if (is_null($this->using_expression)) { + return new c_base_return_null(); + } + + if (isset($this->using_expression)) { + return c_base_return_string::s_new($this->using_expression); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'using_expression', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_using_expression() { + return c_database_string::USING . ' ' . $this->using_expression; + } +} diff --git a/common/database/traits/database_using_index_method.php b/common/database/traits/database_using_index_method.php new file mode 100644 index 0000000..169dfa8 --- /dev/null +++ b/common/database/traits/database_using_index_method.php @@ -0,0 +1,85 @@ +using_index_method = NULL; + return new c_base_return_true(); + } + + if (is_string($using_index_method)) { + $placeholder = $this->add_placeholder($using_index_method); + if ($placeholder->has_error()) { + return c_base_return_error::s_false($placeholder->get_error()); + } + + $this->using_index_method = $placeholder; + unset($placeholder); + + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'using_index_method', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned using_index_method. + * + * @return i_database_query_placeholder|c_base_return_null + * A using_index_method query placeholder on success. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_using_index_method() { + if (is_null($this->using_index_method)) { + return new c_base_return_null(); + } + + if (isset($this->using_index_method)) { + return clone($this->using_index_method); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'using_index_method', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_using_index_method() { + return strval($this->using_index_method); + } +} diff --git a/common/database/traits/database_version.php b/common/database/traits/database_version.php new file mode 100644 index 0000000..21fb5dd --- /dev/null +++ b/common/database/traits/database_version.php @@ -0,0 +1,85 @@ +version = NULL; + return new c_base_return_true(); + } + + if (is_string($version)) { + $placeholder = $this->add_placeholder($version); + if ($placeholder->has_error()) { + return c_base_return_error::s_false($placeholder->get_error()); + } + + $this->version = $placeholder; + unset($placeholder); + + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'version', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned on version settings. + * + * @return i_database_query_placeholder|c_base_return_null + * A version query placeholder on success. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_version() { + if (is_null($this->version)) { + return new c_base_return_null(); + } + + if (isset($this->version)) { + return clone($this->version); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'version', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_version() { + return strval($this->version); + } +} diff --git a/common/database/traits/database_with_check_expression.php b/common/database/traits/database_with_check_expression.php new file mode 100644 index 0000000..3591eb2 --- /dev/null +++ b/common/database/traits/database_with_check_expression.php @@ -0,0 +1,80 @@ +with_check_expression = NULL; + return new c_base_return_true(); + } + + if (is_string($sql_expression)) { + $this->with_check_expression = $sql_expression; + return new c_base_return_true(); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'sql_expression', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + /** + * Get the currently assigned WITH CHECK expression settings. + * + * @return c_base_return_string|c_base_return_null + * A name query placeholder on success. + * NULL is returned if not set. + * NULL with the error bit set is returned on error. + */ + public function get_with_check_expression() { + if (is_null($this->with_check_expression)) { + return new c_base_return_null(); + } + + if (isset($this->with_check_expression)) { + return c_base_return_string::s_new($this->with_check_expression); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_check_expression', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_with_check_expression() { + return c_database_string::WITH_CHECK . ' ' . $this->with_check_expression; + } +} diff --git a/common/database/traits/database_with_publication_option.php b/common/database/traits/database_with_publication_option.php new file mode 100644 index 0000000..1b6695f --- /dev/null +++ b/common/database/traits/database_with_publication_option.php @@ -0,0 +1,135 @@ +with_publication_option = NULL; + return new c_base_return_true(); + } + + switch ($option) { + case e_database_publication_option::REFRESH: + break; + default: + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_bool($value)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->with_publication_option)) { + $this->with_publication_option = []; + } + + $this->with_publication_option[] = [ + 'option' => $option, + 'value' => $value, + ]; + + return new c_base_return_true(); + } + + /** + * Get the currently assigned WITH publication option at the specified index. + * + * @param int|null $index + * (optional) Get the publication options at the specified index. + * When NULL, all publication options are returned. + * + * @return c_base_return_array|c_base_return_null + * An array containing the with publication option settings on success. + * NULL is returned if not set (with publication option not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_with_publication_option($index = NULL) { + if (is_null($this->with_publication_option)) { + return new c_base_return_null(); + } + + if (is_null($index)) { + if (is_array($this->with_publication_option)) { + return c_base_return_array::s_new($this->with_publication_option); + } + } + else { + if (is_int($index) && array_key_exists($index, $this->with_publication_option)) { + return c_base_return_array::s_new($this->with_publication_option[$index]); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_publication_option[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_publication_option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_with_publication_option() { + $values = []; + foreach ($this->with_publication_option as $option) { + if ($parameter === e_database_publication_option::REFRESH) { + $value = c_database_string::REFRESH . ' = '; + + if ($option) { + $value .= c_database_string::TRUE; + } + else { + $value .= c_database_string::FALSE; + } + + $values[] = $value; + } + } + unset($option); + unset($value); + + return c_database_string::WITH . ' (' . implode(', ', $values) . ')'; + } +} diff --git a/common/database/traits/database_with_refresh_option.php b/common/database/traits/database_with_refresh_option.php new file mode 100644 index 0000000..77c458c --- /dev/null +++ b/common/database/traits/database_with_refresh_option.php @@ -0,0 +1,135 @@ +with_refresh_option = NULL; + return new c_base_return_true(); + } + + switch ($option) { + case e_database_refresh_option::REFRESH: + break; + default: + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_bool($value)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->with_refresh_option)) { + $this->with_refresh_option = []; + } + + $this->with_refresh_option[] = [ + 'option' => $option, + 'value' => $value, + ]; + + return new c_base_return_true(); + } + + /** + * Get the currently assigned WITH refresh option at the specified index. + * + * @param int|null $index + * (optional) Get the refresh options at the specified index. + * When NULL, all refresh options are returned. + * + * @return c_base_return_array|c_base_return_null + * An array containing the with refresh option settings on success. + * NULL is returned if not set (with refresh option not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_with_refresh_option($index = NULL) { + if (is_null($this->with_refresh_option)) { + return new c_base_return_null(); + } + + if (is_null($index)) { + if (is_array($this->with_refresh_option)) { + return c_base_return_array::s_new($this->with_refresh_option); + } + } + else { + if (is_int($index) && array_key_exists($index, $this->with_refresh_option)) { + return c_base_return_array::s_new($this->with_refresh_option[$index]); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_refresh_option[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_refresh_option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_with_refresh_option() { + $values = []; + foreach ($this->with_refresh_option as $option) { + if ($parameter === e_database_refresh_option::COPY_DATA) { + $value = c_database_string::COPY_DATA . ' = '; + + if ($option) { + $value .= c_database_string::TRUE; + } + else { + $value .= c_database_string::FALSE; + } + + $values[] = $value; + } + } + unset($option); + unset($value); + + return c_database_string::WITH . ' (' . implode(', ', $values) . ')'; + } +} diff --git a/common/database/traits/database_with_role_option.php b/common/database/traits/database_with_role_option.php new file mode 100644 index 0000000..a3ed53b --- /dev/null +++ b/common/database/traits/database_with_role_option.php @@ -0,0 +1,209 @@ +with_role_option = NULL; + return new c_base_return_true(); + } + + $role_option = [ + 'type' => $type, + 'value' => NULL, + ]; + + switch ($type) { + case e_database_role_option::BYPASSRLS: + case e_database_role_option::CREATEDB: + case e_database_role_option::CREATEROLE: + case e_database_role_option::INHERIT: + case e_database_role_option::LOGIN: + case e_database_role_option::NOBYPASSRLS: + case e_database_role_option::NOCREATEDB: + case e_database_role_option::NOCREATEROLE: + case e_database_role_option::NOINHERIT: + case e_database_role_option::NOLOGIN: + case e_database_role_option::NOREPLICATION: + case e_database_role_option::NOSUPERUSER: + case e_database_role_option::REPLICATION: + case e_database_role_option::SUPERUSER: + break; + + case e_database_role_option::CONNECTION_LIMIT: + if (is_int($value)) { + $role_option['value'] = $value; + } + else if (!is_null($value)) { + unset($role_option); + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + break; + + case e_database_role_option::PASSWORD: + case e_database_role_option::PASSWORD_ENCRYPTED: + case e_database_role_option::VALIDUNTIL: + if (is_string($value)) { + $placeholder = $this->add_placeholder($value); + if ($placeholder->has_error()) { + unset($role_option); + return c_base_return_error::s_false($placeholder->get_error()); + } + + $role_option['value'] = $placeholder; + unset($placeholder); + } + else if (!is_null($value)) { + unset($role_option); + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + break; + + default: + unset($role_option); + $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 (!is_array($this->with_role_option)) { + $this->with_role_option = []; + } + + $this->with_role_option[] = $role_option; + unset($role_option); + + return new c_base_return_true(); + } + + /** + * Get the with role option settings. + * + * @return c_base_return_array|c_base_return_null + * An array of with role option settings on success. + * NULL is returned if not set (with role option is not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_with_role_option() { + if (is_null($this->with_role_option)) { + return new c_base_return_null(); + } + + if (is_array($this->with_role_option)) { + return c_base_return_array::s_new($this->with_role_option); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_role_option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_with_role_option() { + $values = []; + foreach ($this->with_role_option as $role_option) { + if ($role_option['type'] === e_database_role_option::BYPASSRLS) { + $values[] = c_database_string::BYPASSRLS; + } + else if ($role_option['type'] === e_database_role_option::CREATEDB) { + $values[] = c_database_string::CREATEDB; + } + else if ($role_option['type'] === e_database_role_option::CREATEROLE) { + $values[] = c_database_string::CREATEROLE; + } + else if ($role_option['type'] === e_database_role_option::INHERIT) { + $values[] = c_database_string::INHERIT; + } + else if ($role_option['type'] === e_database_role_option::LOGIN) { + $values[] = c_database_string::LOGIN; + } + else if ($role_option['type'] === e_database_role_option::NOBYPASSRLS) { + $values[] = c_database_string::NOBYPASSRLS; + } + else if ($role_option['type'] === e_database_role_option::NOCREATEDB) { + $values[] = c_database_string::NOCREATEDB; + } + else if ($role_option['type'] === e_database_role_option::NOCREATEROLE) { + $values[] = c_database_string::NOCREATEROLE; + } + else if ($role_option['type'] === e_database_role_option::NOINHERIT) { + $values[] = c_database_string::NOINHERIT; + } + else if ($role_option['type'] === e_database_role_option::NOLOGIN) { + $values[] = c_database_string::NOLOGIN; + } + else if ($role_option['type'] === e_database_role_option::NOREPLICATION) { + $values[] = c_database_string::NOREPLICATION; + } + else if ($role_option['type'] === e_database_role_option::NOSUPERUSER) { + $values[] = c_database_string::NOSUPERUSER; + } + else if ($role_option['type'] === e_database_role_option::REPLICATION) { + $values[] = c_database_string::REPLICATION; + } + else if ($role_option['type'] === e_database_role_option::SUPERUSER) { + $values[] = c_database_string::SUPERUSER; + } + else if ($role_option['type'] === e_database_role_option::CONNECTION_LIMIT) { + $values[] = c_database_string::CONNECTION_LIMIT . ' ' . $role_option['value']; + } + else if ($role_option['type'] === e_database_role_option::PASSWORD) { + $values[] = c_database_string::PASSWORD . ' ' . $role_option['value']; + } + else if ($role_option['type'] === e_database_role_option::PASSWORD_ENCRYPTED) { + $values[] = c_database_string::PASSWORD_ENCRYPTED . ' ' . $role_option['value']; + } + else if ($role_option['type'] === e_database_role_option::VALIDUNTIL) { + $values[] = c_database_string::VALIDUNTIL . ' ' . $role_option['value']; + } + } + unset($role_option); + + $value = c_database_string::WITH; + $value .= ' ' . implode(', ', $values); + unset($values); + + return $value; + } +} diff --git a/common/database/traits/database_with_storage_parameter.php b/common/database/traits/database_with_storage_parameter.php new file mode 100644 index 0000000..0af7ea4 --- /dev/null +++ b/common/database/traits/database_with_storage_parameter.php @@ -0,0 +1,152 @@ +with_storage_parameter = NULL; + return new c_base_return_true(); + } + + switch ($parameter) { + case e_database_storage_parameter::AUTOSUMMARIZE: + case e_database_storage_parameter::BUFFERING: + case e_database_storage_parameter::FASTUPDATE: + case e_database_storage_parameter::FILLFACTOR: + case e_database_storage_parameter::GIN_PENDING_LIST_LIMIT: + case e_database_storage_parameter::PAGES_PER_RANGE: + break; + default: + $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); + } + + if (!is_string($value)) { + $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->with_storage_parameter)) { + $this->with_storage_parameter = []; + } + + $placeholder = $this->add_placeholder($value); + if ($placeholder->has_error()) { + return c_base_return_error::s_false($placeholder->get_error()); + } + + $this->with_storage_parameter[] = [ + 'type' => $parameter, + 'value' => $placeholder, + ]; + unset($placeholder); + + return new c_base_return_true(); + } + + /** + * Get the currently assigned WITH index storage parameter at the specified index. + * + * @param int|null $index + * (optional) Get the index storage parameter type at the specified index. + * When NULL, all index storage parameter types are returned. + * + * @return c_base_return_array|c_base_return_null + * An array containing the set index storage parameter settings on success. + * NULL is returned if not set (set index storage parameter not to be used). + * NULL with the error bit set is returned on error. + */ + public function get_with_storage_parameter($index = NULL) { + if (is_null($this->with_storage_parameter)) { + return new c_base_return_null(); + } + + if (is_null($index)) { + if (is_array($this->with_storage_parameter)) { + return c_base_return_array::s_new($this->with_storage_parameter); + } + } + else { + if (is_int($index) && array_key_exists($index, $this->with_storage_parameter)) { + return c_base_return_array::s_new($this->with_storage_parameter[$index]); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_storage_parameter[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_storage_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE); + return c_base_return_error::s_null($error); + } + + /** + * Perform the common build process for this trait. + * + * As an internal trait method, the caller is expected to perform any appropriate validation. + * + * @return string|null + * 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_with_storage_parameter() { + $values = []; + foreach ($this->with_storage_parameter as $parameter => $value) { + if ($parameter === e_database_storage_parameter::AUTOSUMMARIZE) { + $values[] = c_database_string::AUTOSUMMARIZE . ' = ' . $value; + } + else if ($parameter === e_database_storage_parameter::BUFFERING) { + $values[] = c_database_string::BUFFERING . ' = ' . $value; + } + else if ($parameter === e_database_storage_parameter::FASTUPDATE) { + $values[] = c_database_string::FASTUPDATE . ' = ' . $value; + } + else if ($parameter === e_database_storage_parameter::FILLFACTOR) { + $values[] = c_database_string::FILLFACTOR . ' = ' . $value; + } + else if ($parameter === e_database_storage_parameter::GIN_PENDING_LIST_LIMIT) { + $values[] = c_database_string::GIN_PENDING_LIST_LIMIT . ' = ' . $value; + } + else if ($parameter === e_database_storage_parameter::PAGES_PER_RANGE) { + $values[] = c_database_string::PAGES_PER_RANGE . ' = ' . $value ; + } + } + unset($parameter); + unset($value); + + return c_database_string::WITH . ' (' . implode(', ', $values) . ')'; + } +} -- 1.8.3.1