* Instead, use pg_escape_bytea() or a large object function.
*
* @return c_base_database_result
- * Query resource is returned on success.
+ * Query resource is returned.
* Query resource with the error bit set is returned on error.
*
* @see: self::execute()
* The query statement to execute.
*
* @return c_base_database_result
- * Query resource is returned on success.
+ * Query resource is returned.
* Query resource with error bit set is returned on error.
*
* @see: self::execute()
* This is only useful when a query is asynchronous.
*
* @return c_base_database_result
- * A database result is returned on success.
+ * A database result is returned.
* A database result with the error bit set is returned on error.
*/
public function get_result() {
* This design, however, means that only a single a synchronous query operation may be performed at any given time.
*
* @return c_base_return_status
- * TRUE is returned on success.
+ * TRUE is returned.
* FALSE is returned on failure.
* When asynchronous is not enabled, FALSE is returned without an error flag set.
*
*
* @return c_base_return_status|c_base_return_string
* TRUE on success, FALSE on failure.
- * If PGSQL_DML_STRING is set, a string is returned on success.
+ * If PGSQL_DML_STRING is set, a string is returned.
*
* Its unclear as to what the returned string is, but it can be assumed to be a value, such as an serialized number that was incremented by this operation.
*
*
* @return c_base_return_status|c_base_return_string
* TRUE on success, FALSE on failure.
- * If PGSQL_DML_STRING is set, a string is returned on success.
+ * If PGSQL_DML_STRING is set, a string is returned.
*
* Its unclear as to what the returned string is, but it can be assumed to be a value, such as an serialized number that was incremented by this operation.
*
*
* @return c_base_return_status|c_base_return_string|c_base_return_array
* TRUE or an array on success, FALSE on failure.
- * If PGSQL_DML_STRING is set, a string is returned on success.
+ * If PGSQL_DML_STRING is set, a string is returned.
*
* Its unclear as to what the returned string is, but it can be assumed to be a value, such as an serialized number that was incremented by this operation.
*
*
* @return c_base_return_status|c_base_return_string|c_base_return_array
* TRUE on success, FALSE on failure.
- * If PGSQL_DML_STRING is set, a string is returned on success.
+ * If PGSQL_DML_STRING is set, a string is returned.
*
* Its unclear as to what the returned string is, but it can be assumed to be a value, such as an serialized number that was incremented by this operation.
*
* Default setting is assigned on parameter error.
*
* @return c_base_markup_tag|c_base_return_status
- * A newly created tag is returned on success.
+ * A newly created tag is returned.
* FALSE with the error bit set is returned on error.
*/
public static function s_create_alias($id_group, $field_path, $field_destination, $is_private = TRUE) {
* Default setting is assigned on parameter error.
*
* @return c_base_markup_tag|c_base_return_status
- * A newly created tag is returned on success.
+ * A newly created tag is returned.
* FALSE with the error bit set is returned on error.
*/
public static function s_create_redirect($field_destination, $field_response_code, $is_private = TRUE) {
* (optional) An array of additional settings that are usually site-specific.
*
* @return c_base_path_executed|int
- * An executed array object is returned on success.
+ * An executed array object is returned.
* An executed array object with error bit set is returned on error.
*/
public function do_execute(&$http, &$database, &$session, $settings = []) {
* When NULL, the cookies array is reset to an empty array.
*
* @return c_base_return_status
- * TRUE is returned on success.
+ * TRUE is returned.
* FALSE with error bit set is returned on error.
*/
public function set_cookies($cookie) {
* NULL may be specified to remove any output.
*
* @return c_base_return_status
- * TRUE is returned on success.
+ * TRUE is returned.
* FALSE with error bit set is returned on error.
*/
public function set_output($output) {
* The group id to assign.
*
* @return c_base_return_status
- * TRUE is returned on success.
+ * TRUE is returned.
* FALSE with error bit set is returned on error.
*/
public function set_id_group($id_group) {
require_once('common/database/classes/database_query.php');
-require_once('common/database/traits/database_action.php');
require_once('common/database/traits/database_handler.php');
require_once('common/database/traits/database_name.php');
require_once('common/database/traits/database_options.php');
* @see: https://www.postgresql.org/docs/current/static/sql-alterforeigndatawrapper.html
*/
class c_database_alter_foreign_data_wrapper extends c_database_query {
- use t_database_action;
use t_database_handler;
use t_database_name;
use t_database_options;
public function __construct() {
parent::__construct();
- $this->action = NULL;
$this->handler = NULL;
$this->name = NULL;
$this->options = NULL;
* Class destructor.
*/
public function __destruct() {
- unset($this->action);
unset($this->handler);
unset($this->name);
unset($this->options);
return new c_base_return_false();
}
+ // @fixme: rewrite this.
$value = NULL;
if ($this->action === e_database_action::OWNER_TO) {
if (isset($this->owner_to)) {
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
-require_once('common/database/classes/database_alter_foeign_table_action.php');
require_once('common/database/classes/database_query.php');
+require_once('common/database/traits/database_action_add_column.php');
+require_once('common/database/traits/database_action_add_constraint.php');
+require_once('common/database/traits/database_action_alter_column.php');
+require_once('common/database/traits/database_action_alter_column_options.php');
+require_once('common/database/traits/database_action_alter_column_reset.php');
+require_once('common/database/traits/database_action_alter_column_set.php');
+require_once('common/database/traits/database_action_disable_trigger.php');
+require_once('common/database/traits/database_action_drop_columm.php');
+require_once('common/database/traits/database_action_drop_constraint.php');
+require_once('common/database/traits/database_action_enable_trigger.php');
+require_once('common/database/traits/database_action_inherit.php');
+require_once('common/database/traits/database_action_options.php');
+require_once('common/database/traits/database_action_owner_to.php');
+require_once('common/database/traits/database_action_set_oids.php');
+require_once('common/database/traits/database_action_validate_constraint.php');
+require_once('common/database/traits/database_if_exists.php');
require_once('common/database/traits/database_name.php');
+require_once('common/database/traits/database_only.php');
require_once('common/database/traits/database_rename_column.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_wildcard.php');
/**
* The class for building and returning a Postgresql ALTER FOREIGN TABLE query string.
* @see: https://www.postgresql.org/docs/current/static/sql-alterforeigntable.html
*/
class c_database_alter_foreign_table extends c_database_query {
+ use t_database_action_add_column;
+ use t_database_action_add_constraint;
+ use t_database_action_alter_column;
+ use t_database_action_alter_column_options;
+ use t_database_action_alter_column_reset;
+ use t_database_action_alter_column_set;
+ use t_database_action_alter_constraint;
+ use t_database_action_disable_trigger;
+ use t_database_action_drop_columm;
+ use t_database_action_drop_constraint;
+ use t_database_action_enable_trigger;
+ use t_database_action_inherit;
+ use t_database_action_options;
+ use t_database_action_owner_to;
+ use t_database_action_set_oids;
+ use t_database_action_validate_constraint;
+ use t_database_if_exists;
use t_database_name;
+ use t_database_only;
use t_database_rename_column;
use t_database_rename_to;
use t_database_set_schema;
+ use t_database_wildcard;
protected const p_QUERY_COMMAND = 'alter foreign table';
- protected $actions;
- protected $if_exists;
- protected $include_descendents; // The '*' following 'name'
- protected $only;
/**
* Class constructor.
public function __construct() {
parent::__construct();
- $this->name = NULL;
- $this->rename_column = NULL;
- $this->rename_to = NULL;
- $this->set_schema = NULL;
-
- $this->actions = NULL;
- $this->if_exists = NULL;
- $this->include_descendents = NULL;
- $this->only = NULL;
+ $this->action_add_column = NULL;
+ $this->action_add_constraint = NULL;
+ $this->action_alter_column = NULL;
+ $this->action_alter_column_options = NULL;
+ $this->action_alter_column_reset = NULL;
+ $this->action_alter_column_set = NULL;
+ $this->action_alter_constraint = NULL;
+ $this->action_disable_trigger = NULL;
+ $this->action_drop_columm = NULL;
+ $this->action_drop_constraint = NULL;
+ $this->action_enable_trigger = NULL;
+ $this->action_inherit = NULL;
+ $this->action_options = NULL;
+ $this->action_owner_to = NULL;
+ $this->action_set_oids = NULL;
+ $this->action_validate_constraint = NULL;
+ $this->if_exists = NULL;
+ $this->name = NULL;
+ $this->only = NULL;
+ $this->rename_column = NULL;
+ $this->rename_to = NULL;
+ $this->set_schema = NULL;
+ $this->wildcard = NULL;
}
/**
public function __destruct() {
parent::__destruct();
+ unset($this->action_add_column);
+ unset($this->action_add_constraint);
+ unset($this->action_alter_column);
+ unset($this->action_alter_column_options);
+ unset($this->action_alter_column_reset);
+ unset($this->action_alter_column_set);
+ unset($this->action_alter_constraint);
+ unset($this->action_disable_trigger);
+ unset($this->action_drop_columm);
+ unset($this->action_drop_constraint);
+ unset($this->action_enable_trigger);
+ unset($this->action_inherit);
+ unset($this->action_options);
+ unset($this->action_owner_to);
+ unset($this->action_set_oids);
+ unset($this->action_validate_constraint);
+ unset($this->if_exists);
unset($this->name);
+ unset($this->only);
unset($this->rename_column);
unset($this->rename_to);
unset($this->set_schema);
-
- unset($this->actions);
- unset($this->if_exists);
- unset($this->include_descendents);
- unset($this->only);
+ unset($this->wildcard);
}
/**
}
/**
- * Set or append and action.
- *
- * @param c_database_alter_foreign_table_action|null $action
- * A specific action to this class.
- * Set to NULL to disable.
- * When NULL, this will remove all actions.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- * FALSE with error bit set is returned on error.
+ * Implements do_build().
*/
- public function set_action($action) {
- if (is_null($action)) {
- $this->actions = NULL;
- return new c_base_return_true();
+ public function do_build() {
+ if (is_null($this->name)) {
+ return new c_base_return_false();
}
- if (is_string($action)) {
- if (!is_array($this->actions)) {
- $this->actions = [];
- }
-
- $this->actions[] = $action;
- }
- else {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'action', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ $if_exists = NULL;
+ if ($this->if_exists) {
+ $if_exists = $this->p_do_build_if_exists() . ' ';
}
- return new c_base_return_true();
- }
-
- /**
- * Assigns IF EXISTS.
- *
- * @param bool|null $if_exists
- * Set to TRUE to enable IF EXISTS, FALSE to disable.
- * Set to NULL to disable.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- * FALSE with error bit set is returned on error.
- */
- public function set_if_exists($if_exists) {
- if (is_null($if_exists)) {
- $this->if_exists = NULL;
- return new c_base_return_true();
+ $only = NULL;
+ if ($this->only) {
+ $only = $this->p_do_build_only() . ' ';
}
- if (is_bool($if_exists)) {
- $this->if_exists = $if_exists;
- return new c_base_return_true();
+ $wildcard = NULL;
+ if ($this->wildcard) {
+ $wildcard = ' ' . $this->p_do_build_wildcard();
}
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'if_exists', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- /**
- * Assigns wildcard '*' after the table name.
- *
- * @param bool|null $include_decendents
- * Set to TRUE to enable wildcard '*', FALSE to disable.
- * Set to NULL to disable.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- * FALSE with error bit set is returned on error.
- */
- public function set_include_decendents($include_decendents) {
- if (is_null($include_decendents)) {
- $this->include_decendents = NULL;
- return new c_base_return_true();
+ $value = $this->p_do_build_name();
+ if (isset($this->rename_column)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_rename_column();
}
-
- if (is_bool($include_decendents)) {
- $this->include_decendents = $include_decendents;
- return new c_base_return_true();
+ else if (isset($this->rename_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_rename_constraint();
}
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'include_decendents', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
- /**
- * Assigns ONLY.
- *
- * @param bool|null $only
- * Set to TRUE to enable ONLY, FALSE to disable.
- * Set to NULL to disable.
- *
- * @return c_base_return_status
- * TRUE on success, FALSE otherwise.
- * FALSE with error bit set is returned on error.
- */
- public function set_only($only) {
- if (is_null($only)) {
- $this->only = NULL;
- return new c_base_return_true();
+ else if (isset($this->rename_to)) {
+ $value = $if_exists . $value . ' ' . $this->p_do_build_rename_to();
}
-
- if (is_bool($only)) {
- $this->only = $only;
- return new c_base_return_true();
+ else if (isset($this->set_schema)) {
+ $value = $if_exists . $value . ' ' . $this->p_do_build_set_schema();
}
-
- $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);
- }
-
- /**
- * Get an action or all actions.
- *
- * @param int|null $index
- * (optional) Get the action at the specified index.
- * When NULL, all actions are returned.
- *
- * @return c_database_alter_foreign_table_action|c_base_return_array|c_base_return_null
- * An array of actions or NULL if not defined.
- * A single action is returned if $index is an integer.
- * NULL with the error bit set is returned on error.
- */
- public function get_action($index = NULL) {
- if (is_null($this->actions)) {
- return new c_base_return_null();
+ else if (isset($this->action_add_column)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_add_column();
}
-
- if (is_null($index)) {
- if (is_array($this->actions)) {
- return c_base_return_array::s_new($this->actions);
- }
+ else if (isset($this->action_add_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_add_constraint();
}
- else {
- if (is_int($index) && array_key_exists($index, $this->actions) && $this->actions[$index] instanceof c_database_alter_foreign_table_action) {
- return $this->actions[$index];
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'actions[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ else if (isset($this->action_alter_column)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column();
}
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'actions', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
- }
-
- /**
- * Get the if exists setting.
- *
- * @return c_base_return_bool|c_base_return_null
- * A boolean representing the IF EXISTS setting.
- * NULL is returned if not defined.
- * NULL with the error bit set is returned on error.
- */
- public function get_if_exists($index = NULL) {
- if (is_null($this->if_exists)) {
- return new c_base_return_null();
+ else if (isset($this->action_alter_column_options)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_options();
}
-
- if (is_bool($index)) {
- return c_base_return_bool::s_new($this->if_exists);
+ else if (isset($this->action_alter_column_reset)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_reset();
}
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'if_exists', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
- }
-
- /**
- * Get the include decendents setting.
- *
- * @return c_base_return_bool|c_base_return_null
- * A boolean representing the '*' setting.
- * NULL is returned if not defined.
- * NULL with the error bit set is returned on error.
- */
- public function get_include_decendents($index = NULL) {
- if (is_null($this->include_decendents)) {
- return new c_base_return_null();
+ else if (isset($this->action_alter_column_set)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_set();
}
-
- if (is_bool($index)) {
- return c_base_return_bool::s_new($this->include_decendents);
+ else if (isset($this->action_alter_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_constraint();
}
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'include_decendents', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
- }
-
- /**
- * Get the set only setting.
- *
- * @return c_base_return_bool|c_base_return_null
- * A boolean representing the ONLY setting.
- * NULL is returned if not defined.
- * NULL with the error bit set is returned on error.
- */
- public function get_set_only($index = NULL) {
- if (is_null($this->set_only)) {
- return new c_base_return_null();
+ else if (isset($this->action_disable_trigger)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_disable_trigger();
}
-
- if (is_bool($index)) {
- return c_base_return_bool::s_new($this->set_only);
+ else if (isset($this->action_drop_columm)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_drop_columm();
}
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_only', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
- }
-
- /**
- * Implements do_build().
- */
- public function do_build() {
- if (is_null($this->name)) {
- return new c_base_return_false();
+ else if (isset($this->action_drop_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_drop_constraint();
}
-
- $value = NULL;
- if ($this->if_exists) {
- $value = ' ' . c_database_string::IF_EXISTS;
+ else if (isset($this->action_enable_trigger)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_enable_trigger();
}
-
- if (is_array($this->rename_column)) {
- if ($this->only) {
- $value .= is_null($value) ? '' : ' ';
- $value .= c_database_string::ONLY;
- }
-
- $value .= ' ' . $this->p_do_build_rename_column();
+ else if (isset($this->action_inherit)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_inherit();
}
- else if (isset($this->rename_to)) {
- $value .= is_null($value) ? '' : ' ';
- $value .= $this->p_do_build_rename_to();
+ else if (isset($this->action_options)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_options();
+ }
+ else if (isset($this->action_owner_to)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_owner_to();
+ }
+ else if (isset($this->action_set_oids)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_set_oids();
}
- else if (is_array($this->set_schema)) {
- $value .= is_null($value) ? '' : ' ';
- $value .= $this->p_do_build_set_schema();
+ else if (isset($this->action_validate_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_validate_constraint();
}
else {
- if ($this->only) {
- $value .= is_null($value) ? '' : ' ';
- $value .= c_database_string::ONLY;
- }
-
- $value .= is_null($value) ? '' : ' ';
- if (is_array($this->actions) && !empty($this->actions)) {
- $actions = [];
- foreach ($this->actions as $action) {
- if ($action instanceof c_database_alter_foreign_table_action && $action->do_build() instanceof c_base_return_true) {
- $actions[] = $action->get_value_exact();
- }
- }
- unset($action);
-
- $value .= implode(', ', $actions);
- unset($actions);
- }
- else {
- unset($value);
- return new c_base_return_false();
- }
+ unset($value);
+ unset($if_exists);
+ unset($only);
+ unset($wildcard);
+ return new c_base_return_false();
}
+ unset($if_exists);
+ unset($only);
+ unset($wildcard);
$this->value = static::p_QUERY_COMMAND;
- $this->value .= ' ' . $this->p_do_build_name();
-
- if ($this->include_descendents) {
- $this->value .' *';
- }
-
$this->value .= ' ' . $value;
unset($value);
require_once('common/database/classes/database_query.php');
-require_once('common/database/traits/database_all_in_tablespace.php');
require_once('common/database/traits/database_cluster_on.php');
require_once('common/database/traits/database_column_reset.php');
require_once('common/database/traits/database_column_set.php');
* @see: https://www.postgresql.org/docs/current/static/sql-altermaterializedview.html
*/
class c_database_alter_materialized_view extends c_database_query {
- use t_database_all_in_tablespace;
use t_database_cluster_on;
use t_database_column_reset;
use t_database_column_set;
public function __construct() {
parent::__construct();
- $this->all_in_tablespace = NULL;
$this->cluster_on = NULL;
$this->column_reset = NULL;
$this->column_set = NULL;
* Class destructor.
*/
public function __destruct() {
- unset($this->all_in_tablespace);
unset($this->cluster_on);
unset($this->column_reset);
unset($this->column_set);
require_once('common/database/classes/database_query.php');
+require_once('common/database/traits/database_reset_configuration_parameter.php');
+require_once('common/database/traits/database_set_configuration_parameter.php');
+
/**
- * The class for building and returning a Postgresql ALTER COALATION query string.
+ * The class for building and returning a Postgresql ALTER SYSTEM query string.
*
- * @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html
+ * @see: https://www.postgresql.org/docs/current/static/sql-altersystem.html
*/
-class c_database_alter_coalation extends c_database_query {
- protected const p_QUERY_COMMAND = 'alter coalation';
+class c_database_alter_system extends c_database_query {
+ use t_database_reset_configuration_parameter;
+ use t_database_set_configuration_parameter;
+
+ protected const p_QUERY_COMMAND = 'alter system';
/**
*/
public function __construct() {
parent::__construct();
+
+ $this->action_validate_constraint = NULL;
+ $this->reset_configuration_parameter = NULL;
+ $this->set_configuration_parameter = NULL;
}
/**
* Class destructor.
*/
public function __destruct() {
+ unset($this->reset_configuration_parameter);
+ unset($this->set_configuration_parameter);
+
parent::__destruct();
}
* Implements do_build().
*/
public function do_build() {
- if (is_null($this->name)) {
+ $value = NULL;
+ if (isset($this->set_configuration_parameter)) {
+ $value = $this->p_do_build_set_configuration_parameter();
+ }
+ else if (isset($this->set_configuration_parameter)) {
+ $value = $this->p_do_build_set_configuration_parameter();
+ }
+ else {
+ unset($value);
return new c_base_return_false();
}
- $value = $this->p_do_build_name();
-
$this->value = static::p_QUERY_COMMAND;
$this->value .= ' ' . $value;
unset($value);
<?php
/**
* @file
- * Provides a class for specific Postgesql query: ALTER COALATION.
+ * Provides a class for specific Postgesql query: ALTER TABLE.
*/
namespace n_koopa;
require_once('common/database/classes/database_query.php');
+require_once('common/database/traits/database_action_add_column.php');
+require_once('common/database/traits/database_action_add_constraint.php');
+require_once('common/database/traits/database_action_alter_column.php');
+require_once('common/database/traits/database_action_alter_column_options.php');
+require_once('common/database/traits/database_action_alter_column_reset.php');
+require_once('common/database/traits/database_action_alter_column_set.php');
+require_once('common/database/traits/database_action_alter_constraint.php');
+require_once('common/database/traits/database_action_disable_trigger.php');
+require_once('common/database/traits/database_action_drop_columm.php');
+require_once('common/database/traits/database_action_drop_constraint.php');
+require_once('common/database/traits/database_action_enable_trigger.php');
+require_once('common/database/traits/database_action_inherit.php');
+require_once('common/database/traits/database_action_owner_to.php');
+require_once('common/database/traits/database_action_set_oids.php');
+require_once('common/database/traits/database_action_validate_constraint.php');
+require_once('common/database/traits/database_attach_partition.php');
+require_once('common/database/traits/database_detach_partition.php');
+require_once('common/database/traits/database_if_exists.php');
+require_once('common/database/traits/database_name.php');
+require_once('common/database/traits/database_no_wait.php');
+require_once('common/database/traits/database_only.php');
+require_once('common/database/traits/database_owned_by.php');
+require_once('common/database/traits/database_rename_column.php');
+require_once('common/database/traits/database_rename_constraint.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_set_tablespace.php');
+require_once('common/database/traits/database_wildcard.php');
+
/**
- * The class for building and returning a Postgresql ALTER COALATION query string.
+ * The class for building and returning a Postgresql ALTER TABLE query string.
*
- * @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html
+ * @see: https://www.postgresql.org/docs/current/static/sql-altertable.html
*/
-class c_database_alter_coalation extends c_database_query {
- protected const p_QUERY_COMMAND = 'alter coalation';
+class c_database_alter_table extends c_database_query {
+ use t_database_action_add_column;
+ use t_database_action_add_constraint;
+ use t_database_action_alter_column;
+ use t_database_action_alter_column_options;
+ use t_database_action_alter_column_reset;
+ use t_database_action_alter_column_set;
+ use t_database_action_alter_constraint;
+ use t_database_action_disable_trigger;
+ use t_database_action_drop_columm;
+ use t_database_action_drop_constraint;
+ use t_database_action_enable_trigger;
+ use t_database_action_inherit;
+ use t_database_action_owner_to;
+ use t_database_action_set_oids;
+ use t_database_action_validate_constraint;
+ use t_database_attach_partition;
+ use t_database_detach_partition;
+ use t_database_if_exists;
+ use t_database_name;
+ use t_database_no_wait;
+ use t_database_only;
+ use t_database_owned_by;
+ use t_database_rename_column;
+ use t_database_rename_constraint;
+ use t_database_rename_to;
+ use t_database_set_schema;
+ use t_database_set_tablespace;
+ use t_database_wildcard;
+
+ protected const p_QUERY_COMMAND = 'alter table';
/**
*/
public function __construct() {
parent::__construct();
+
+ $this->action_add_column = NULL;
+ $this->action_add_constraint = NULL;
+ $this->action_alter_column = NULL;
+ $this->action_alter_column_options = NULL;
+ $this->action_alter_column_reset = NULL;
+ $this->action_alter_column_set = NULL;
+ $this->action_alter_constraint = NULL;
+ $this->action_disable_trigger = NULL;
+ $this->action_drop_columm = NULL;
+ $this->action_drop_constraint = NULL;
+ $this->action_enable_trigger = NULL;
+ $this->action_inherit = NULL;
+ $this->action_options = NULL;
+ $this->action_owner_to = NULL;
+ $this->action_set_oids = NULL;
+ $this->attach_partition = NULL;
+ $this->detach_partition = NULL;
+ $this->if_exists = NULL;
+ $this->name = NULL;
+ $this->no_wait = NULL;
+ $this->only = NULL;
+ $this->owned_by = NULL;
+ $this->rename_column = NULL;
+ $this->rename_constraint = NULL;
+ $this->rename_to = NULL;
+ $this->set_schema = NULL;
+ $this->set_tablespace = NULL;
+ $this->wildcard = NULL;
}
/**
* Class destructor.
*/
public function __destruct() {
+ unset($this->action_add_column);
+ unset($this->action_add_constraint);
+ unset($this->action_alter_column);
+ unset($this->action_alter_column_options);
+ unset($this->action_alter_column_reset);
+ unset($this->action_alter_column_set);
+ unset($this->action_alter_constraint);
+ unset($this->action_disable_trigger);
+ unset($this->action_drop_columm);
+ unset($this->action_drop_constraint);
+ unset($this->action_enable_trigger);
+ unset($this->action_inherit);
+ unset($this->action_options);
+ unset($this->action_owner_to);
+ unset($this->action_set_oids);
+ unset($this->action_validate_constraint);
+ unset($this->attach_partition);
+ unset($this->detach_partition);
+ unset($this->if_exists);
+ unset($this->name);
+ unset($this->no_wait);
+ unset($this->only);
+ unset($this->owned_by);
+ unset($this->rename_column);
+ unset($this->rename_constraint);
+ unset($this->rename_to);
+ unset($this->set_schema);
+ unset($this->set_tablespace);
+ unset($this->wildcard);
+
parent::__destruct();
}
return new c_base_return_false();
}
+ $if_exists = NULL;
+ if ($this->if_exists) {
+ $if_exists = $this->p_do_build_if_exists() . ' ';
+ }
+
+ $only = NULL;
+ if ($this->only) {
+ $only = $this->p_do_build_only() . ' ';
+ }
+
+ $wildcard = NULL;
+ if ($this->wildcard) {
+ $wildcard = ' ' . $this->p_do_build_wildcard();
+ }
+
$value = $this->p_do_build_name();
+ if (isset($this->rename_column)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_rename_column();
+ }
+ else if (isset($this->rename_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_rename_constraint();
+ }
+ else if (isset($this->rename_to)) {
+ $value = $if_exists . $wildcard . $this->p_do_build_rename_to();
+ }
+ else if (isset($this->set_schema)) {
+ $value = $if_exists . $wildcard . $this->p_do_build_set_schema();
+ }
+ else if (isset($this->set_tablespace)) {
+ $value = c_database_string::ALL_IN_TABLESPACE . ' ' . $value;
+
+ if (!is_null($this->owned_by)) {
+ $value .= ' ' . $this->p_do_build_owned_by();
+ }
+
+ $value .= ' ' . $this->p_do_build_set_tablespace();
+
+ if (is_bool($this->no_wait)) {
+ $value .= ' ' . $this->p_do_build_no_wait();
+ }
+ }
+ else if (isset($this->attach_partition)) {
+ $value =$if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_attach_partition();
+ }
+ else if (isset($this->detach_partition)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_detach_partition();
+ }
+ else if (isset($this->action_add_column)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_add_column();
+ }
+ else if (isset($this->action_add_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_add_constraint();
+ }
+ else if (isset($this->action_alter_column)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column();
+ }
+ else if (isset($this->action_alter_column_options)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_options();
+ }
+ else if (isset($this->action_alter_column_reset)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_reset();
+ }
+ else if (isset($this->action_alter_column_set)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_set();
+ }
+ else if (isset($this->action_alter_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_constraint();
+ }
+ else if (isset($this->action_disable_trigger)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_disable_trigger();
+ }
+ else if (isset($this->action_drop_columm)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_drop_columm();
+ }
+ else if (isset($this->action_drop_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_drop_constraint();
+ }
+ else if (isset($this->action_enable_trigger)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_enable_trigger();
+ }
+ else if (isset($this->action_inherit)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_inherit();
+ }
+ else if (isset($this->action_options)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_options();
+ }
+ else if (isset($this->action_owner_to)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_owner_to();
+ }
+ else if (isset($this->action_set_oids)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_set_oids();
+ }
+ else if (isset($this->action_validate_constraint)) {
+ $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_validate_constraint();
+ }
+ else {
+ unset($value);
+ unset($if_exists);
+ unset($only);
+ unset($wildcard);
+ return new c_base_return_false();
+ }
+ unset($if_exists);
+ unset($only);
+ unset($wildcard);
$this->value = static::p_QUERY_COMMAND;
$this->value .= ' ' . $value;
* When NULL, the placeholder is appended.
*
* @return i_database_query_placeholder|c_base_return_false
- * A query placeholder representing is returned on success.
+ * A query placeholder representing is returned.
* FALSE with the error bit set is returned on error.
*/
public function add_placeholder($value, $placeholder = NULL) {
class c_database_string {
public const ACCESS_METHOD = 'access method';
public const ADD = 'add';
+ public const ADD_COLUMN = 'add column';
public const ADD_TABLE = 'add table';
public const AGGREGATE = 'aggregate';
public const ALL = 'all';
public const ALTER = 'alter';
public const AS = 'as';
public const ASCEND = 'asc';
+ public const ATTACH_PARTITION = 'attach partition';
public const AUTOSUMMARIZE = 'autosummarize';
public const AUTOVACUUM_ANALYZE_SCALE_FACTOR = 'autovacuum_analyze_scale_factor';
public const AUTOVACUUM_ANALYZE_THRESHOLD = 'autovacuum_analyze_threshold';
public const CASCADE = 'cascade';
public const CAST = 'cast';
public const CLUSTER_ON = 'cluster on';
+ public const COLLATE = 'collate';
public const COLLATION = 'collation';
public const COLUMN = 'column';
public const CONNECT = 'connect';
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 DROP_TABLE = 'drop table';
public const ENABLE = 'enable';
public const ENABLED = 'enabled';
public const ENABLE_ALWAYS_TRIGGER = 'enable always trigger';
public const FOR_ORDER_BY = 'for order by';
public const FOR_ROLE = 'for role';
public const FOR_SEARCH = 'for search';
+ public const FOR_VALUES = 'for values';
public const FROM_CURRENT = 'from current';
public const FUNCTION = 'function';
public const GRANT = 'grant';
public const SEQUENCE = 'sequence';
public const SERVER = 'server';
public const SET = 'set';
+ public const SET_DATA = 'set data';
public const SET_DEFAULT = 'set default';
public const SET_PUBLICATION = 'set publication';
public const SET_SCHEMA = 'set schema';
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides enumeration classes for managing codes used for generating specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+/**
+ * Codes associated with database actions.
+ */
+class e_database_alter_column {
+ public const NONE = 0;
+ public const DROP = 1;
+ public const DROP_DEFAULT = 2;
+ public const SET = 3;
+ public const SET_DATA = 4;
+ public const SET_DEFAULT = 5;
+ public const SET_STATISTICS = 6;
+ public const SET_STORAGE = 7;
+}
* Gets the id used for generating the placeholder name.
*
* @return c_base_return_id|c_base_return_null
- * A value is returned on success.
+ * A value is returned.
* NULL is returned if not assigned.
* NULL with the error bit set is returned on error.
*/
* Gets a placeholder name, generated from the prefix and id.
*
* @return c_base_return_string|c_base_return_null
- * A value is returned on success.
+ * A value is returned.
* NULL is returned if not assigned.
* NULL with the error bit set is returned on error.
*/
* Gets the prefix used for generating the placeholder name.
*
* @return c_base_return_string|c_base_return_null
- * A value is returned on success.
+ * A value is returned.
* NULL with the error bit set is returned on error.
*/
public function get_placeholder();
* Get the currently assigned action.
*
* @return c_base_return_int|c_base_return_null
- * Integer representing the action is returned on success.
+ * Integer representing the action is returned.
* NULL is returned if undefined.
* FALSE with error bit set is returned on error.
*/
* Get the currently assigned action property.
*
* @return c_base_return_int|c_base_return_null
- * Integer representing the action property is returned on success.
+ * Integer representing the action property is returned.
* NULL is returned if undefined.
* FALSE with error bit set is returned on error.
*/
* Get the currently assigned action parameter.
*
* @return c_base_return_string|c_base_return_array|c_database_query|c_base_return_null
- * String or array representing the action parameters are returned on success.
+ * String or array representing the action parameters are returned.
* NULL is returned if undefined.
* FALSE with error bit set is returned on error.
*/
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+/**
+ * Provide the sql action ADD COLUMN functionality.
+ */
+trait t_database_action_add_column {
+ protected $action_add_column;
+
+ /**
+ * Set the action ADD COLUMN settings.
+ *
+ * @param string|null $column_name
+ * The column name to use.
+ * Set to NULL to disable.
+ * @param string|null $data_type
+ * (optional) The data type to use.
+ * Required when $column_name is not NULL and $column_constraint is NULL.
+ * Ignored when $column_name is NULL.
+ * @param string|null $collate
+ * (optional) The collate to use.
+ * Ignored when $column_name is NULL.
+ * @param array|null $column_constraints
+ * (optional) An array of column constraint strings to add.
+ * Ignored when $column_name is NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_action_add_column($column_name, $data_type = NULL, $collate = NULL, $column_constraints = NULL) {
+ if (is_null($column_name)) {
+ $this->action_add_column = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($column_name)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'column_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_string($data_type)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'data_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($collate) && !is_string($collate)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'collate', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($column_constraints) && !is_array($column_constraints)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'column_constraints', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $placeholder_column_name = $this->add_placeholder($column_name);
+ if ($placeholder_column_name->has_error()) {
+ return c_base_return_error::s_false($placeholder_column_name->get_error());
+ }
+
+ $placeholder_data_type = NULL;
+ if (!is_null($data_type)) {
+ $placeholder_data_type = $this->add_placeholder($data_type);
+ if ($placeholder_data_type->has_error()) {
+ unset($placeholder_column_name);
+ return c_base_return_error::s_false($placeholder_data_type->get_error());
+ }
+ }
+
+ $placeholder_collate = NULL;
+ if (!is_null($collate)) {
+ $placeholder_collate = $this->add_placeholder($collate);
+ if ($placeholder_collate->has_error()) {
+ unset($placeholder_column_name);
+ unset($placeholder_data_type);
+ return c_base_return_error::s_false($placeholder_collate->get_error());
+ }
+ }
+
+ $placeholder_constraints = NULL;
+ if (!is_null($column_constraint)) {
+ $placeholder_constraints = [];
+ foreach ($column_constraint as $column_constraint) {
+ if (!is_string($column_constraint)) {
+ unset($column_constraint);
+ unset($placeholder_column_name);
+ unset($placeholder_data_type);
+ unset($placeholder_collate);
+ unset($placeholder_constraints);
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'column_constraints', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $placeholder_constraint = $this->add_placeholder($column_constraint);
+ if ($placeholder_constraint->has_error()) {
+ unset($column_constraint);
+ unset($placeholder_column_name);
+ unset($placeholder_data_type);
+ unset($placeholder_collate);
+ return c_base_return_error::s_false($placeholder_constraint->get_error());
+ }
+
+ $placeholder_constraints[] = $placeholder_constraint;
+ }
+ unset($column_constraint);
+ }
+
+ $this->action_add_column = [
+ 'column_name' => $placeholder_column_name,
+ 'data_type' => $placeholder_data_type,
+ 'collate' => $placeholder_collate,
+ 'column_constraints' => $placeholder_constraints,
+ ];
+ unset($placeholder_column_name);
+ unset($placeholder_data_type);
+ unset($placeholder_collate);
+ unset($placeholder_constraints);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned action add column settings.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing the settings.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_action_add_column() {
+ if (is_null($this->action_add_column)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->action_add_column)) {
+ return c_base_return_array::s_new($this->action_add_column);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_add_column', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_action_add_column() {
+ $value = c_database_string::ADD_COLUMN . ' ' . $this->action_add_column['column_name'] . ' ' . $this->action_add_column['data_type'];
+ if (!is_null($this->action_add_column['collate'])) {
+ $value .= ' ' . $this->action_add_column['collate'];
+ }
+
+ if (isset($this->action_add_column['column_constraints'])) {
+ $value .= ' ' . implode(' ', $this->action_add_column['column_constraints']);
+ }
+
+ return $value;
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/base/enumerations/database_alter_column.php');
+
+/**
+ * Provide the sql action ALTER COLUMN functionality.
+ */
+trait t_database_action_alter_column {
+ protected $action_alter_column;
+
+ /**
+ * Set the action ALTER COLUMN settings.
+ *
+ * @param string|null $column_name
+ * The column name to use.
+ * Set to NULL to disable.
+ * @param int|null $type
+ * (optional) An e_database_alter_column code.
+ * Required when $column_name is not NULL.
+ * Ignored when $column_name is NULL.
+ * @param string|int|bool|null $value
+ * (optional) The value dependent on the $type.
+ * Ignored when $column_name is NULL.
+ * @param string||null $value2
+ * (optional) The value dependent on the $value.
+ * If $value is SET_DATA, then this is a string representing the collation.
+ * Ignored when $value does not utilize this.
+ * Ignored when $column_name is NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_action_alter_column($column_name, $type = NULL, $value = NULL, $value2 = NULL) {
+ if (is_null($column_name)) {
+ $this->action_alter_column = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($column_name)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'column_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $valid_value = false;
+ switch ($type) {
+ case e_database_alter_column::DROP:
+ case e_database_alter_column::SET:
+ $valid_value = is_null($value) || is_bool($value);
+ break;
+
+ case e_database_alter_column::DROP_DEFAULT:
+ break;
+
+ case e_database_alter_column::SET_DATA:
+ $valid_value = is_string($value);
+
+ if (!is_null($value2) && !is_string($value2)) {
+ unset($valid_value);
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value2', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+ break;
+
+ case e_database_alter_column::SET_DEFAULT:
+ $valid_value = is_string($value);
+ break;
+
+ case e_database_alter_column::SET_STATISTICS:
+ $valid_value = is_int($value);
+ break;
+
+ case e_database_alter_column::SET_STORAGE:
+ switch($value) {
+ case e_database_set_storage::EXTENDED:
+ case e_database_set_storage::EXTERNAL:
+ case e_database_set_storage::MAIN:
+ case e_database_set_storage::PLAIN:
+ $valid_value = true;
+ break;
+ }
+ break;
+
+ default:
+ unset($valid_value);
+ $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 (!$valid_value) {
+ unset($valid_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);
+ }
+ unset($invalid_value);
+
+ $placeholder_column_name = $this->add_placeholder($column_name);
+ if ($placeholder_column_name->has_error()) {
+ return c_base_return_error::s_false($placeholder_column_name->get_error());
+ }
+
+ $placeholder_value = $value;
+ if (is_string($value)) {
+ $placeholder_value = $this->add_placeholder($value);
+ if ($placeholder_value->has_error()) {
+ unset($placeholder_column_name);
+ return c_base_return_error::s_false($placeholder_value->get_error());
+ }
+ }
+
+ $placeholder_value2 = NULL;
+ if ($type === e_database_alter_column::SET_DATA) {
+ $placeholder_value2 = $this->add_placeholder($value2);
+ if ($placeholder_value2->has_error()) {
+ unset($placeholder_column_name);
+ unset($placeholder_value);
+ return c_base_return_error::s_false($placeholder_value2->get_error());
+ }
+ }
+
+ $this->action_alter_column = [
+ 'column_name' => $placeholder_column_name,
+ 'type' => $type,
+ 'value' => $placeholder_value,
+ 'value2' => $placeholder_value2,
+ ];
+ unset($placeholder_column_name);
+ unset($placeholder_value);
+ unset($placeholder_value2);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned action alter column settings.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing the settings.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_action_alter_column() {
+ if (is_null($this->action_alter_column)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->action_alter_column)) {
+ return c_base_return_array::s_new($this->action_alter_column);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_alter_column', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_action_alter_column() {
+ $value = c_database_string::ALTER_COLUMN . ' ' . $this->action_alter_column['column_name'];
+
+ switch ($this->action_alter_column['type']) {
+ case e_database_alter_column::DROP:
+ $value .= ' ' . c_database_string::DROP;
+ if ($this->action_alter_column['value']) {
+ $value .= ' ' . c_database_string::NOT_NULL;
+ }
+ break;
+
+ case e_database_alter_column::SET:
+ $value .= ' ' . c_database_string::SET;
+ if ($this->action_alter_column['value']) {
+ $value .= ' ' . c_database_string::NOT_NULL;
+ }
+ break;
+
+ case e_database_alter_column::DROP_DEFAULT:
+ $value .= ' ' . c_database_string::DROP_DEFAULT;
+ break;
+
+ case e_database_alter_column::SET_DATA:
+ $value .= ' ' . c_database_string::SET_DATA;
+ $value .= ' ' . c_database_string::TYPE;
+ $value .= ' ' . strval($this->action_alter_column['value']);
+ if (isset($this->action_alter_column['value2'])) {
+ $value .= ' ' . c_database_string::COLLATE;
+ $value .= ' ' . strval($this->action_alter_column['value2']);
+ }
+ break;
+
+ case e_database_alter_column::SET_DEFAULT:
+ $value .= ' ' . c_database_string::SET_DEFAULT;
+ $value .= ' ' . strval($this->action_alter_column['value']);
+ break;
+
+ case e_database_alter_column::SET_STATISTICS:
+ $value .= ' ' . c_database_string::SET_STATISTICS;
+ $value .= ' ' . $this->action_alter_column['value'];
+ break;
+
+ case e_database_alter_column::SET_STORAGE:
+ $value .= ' ' . c_database_string::SET_STORAGE;
+ if ($this->action_alter_column['value'] === e_database_set_storage::EXTENDED) {
+ $value .= ' ' . c_database_string::EXTENDED;
+ }
+ else if ($this->action_alter_column['value'] === e_database_set_storage::EXTERNAL) {
+ $value .= ' ' . c_database_string::EXTERNAL;
+ }
+ else if ($this->action_alter_column['value'] === e_database_set_storage::MAIN) {
+ $value .= ' ' . c_database_string::MAIN;
+ }
+ else if ($this->action_alter_column['value'] === e_database_set_storage::PLAIN) {
+ $value .= ' ' . c_database_string::PLAIN;
+ }
+ break;
+ }
+
+ return $value;
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/enumerations/database_options.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql action ALTER COLUMN OPTIONS functionality.
+ */
+trait t_database_action_alter_column_options {
+ protected $action_alter_column_options;
+
+ /**
+ * Set the OPTIONS settings.
+ *
+ * @param string|null $column_name
+ * The column name to use.
+ * Set to NULL to disable.
+ * @param int|null $type
+ * (optional) The option type from e_database_options.
+ * This is required when $column_name is not NULL.
+ * @param string|null $option
+ * (optional) The configuration option.
+ * This is required when $column_name is not NULL.
+ * @param string|null $value
+ * (optional) The configuration options value.
+ * This is required when $column_name is not NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_action_alter_column_options($column_name, $type = NULL, $option = NULL, $value = NULL) {
+ if (is_null($column_name)) {
+ $this->action_alter_column_options = NULL;
+ return new c_base_return_true();
+ }
+
+ switch($type) {
+ case e_database_options::ADD:
+ case e_database_options::DROP:
+ case e_database_options::SET:
+ 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_string($option)) {
+ $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_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);
+ }
+
+ $placeholder_name = $this->add_placeholder($name);
+ if ($placeholder_name->has_error()) {
+ return c_base_return_error::s_false($placeholder_name->get_error());
+ }
+
+ $placeholder_option = $this->add_placeholder($option);
+ if ($placeholder_option->has_error()) {
+ unset($placeholder_name);
+ return c_base_return_error::s_false($placeholder_option->get_error());
+ }
+
+ $placeholder_value = $this->add_placeholder($value);
+ if ($placeholder_value->has_error()) {
+ unset($placeholder_name);
+ unset($placeholder_option);
+ return c_base_return_error::s_false($placeholder_value->get_error());
+ }
+
+ if (!is_array($this->action_alter_column_options)) {
+ $this->action_alter_column_options = [
+ 'column_name' => $placeholder_name,
+ 'values' => [],
+ ];
+ }
+
+ $this->action_alter_column_options[] = [
+ 'type' => $type,
+ 'option' => $placeholder_option,
+ 'value' => $placeholder_value,
+ ];
+ unset($placeholder_name);
+ unset($placeholder_option);
+ unset($placeholder_value);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned settings.
+ *
+ * @param int|null $index
+ * (optional) Get the settings at the specified index.
+ * When NULL, all settings are returned.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array of settings or NULL if not defined.
+ * A single settings is returned if $index is an integer.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_action_alter_column_options($index = NULL) {
+ if (is_null($this->action_alter_column_options)) {
+ return new c_base_return_null();
+ }
+
+ if (is_null($index)) {
+ if (is_array($this->action_alter_column_options)) {
+ return c_base_return_array::s_new($this->action_alter_column_options);
+ }
+ }
+ else {
+ if (is_int($index) && array_key_exists($index, $this->action_alter_column_options)) {
+ return c_base_return_array::s_new($this->action_alter_column_options[$index]);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_alter_column_options[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}' => 'action_alter_column_options', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_action_alter_column_options() {
+ $value = c_database_string::ALTER_COLUMN . ' ' . $this->action_alter_column_options['column_name'] . ' ' . c_database_string::OPTIONS;
+
+ $values = [];
+ foreach ($this->action_alter_column_options['values'] as $set) {
+ if ($set['type'] === e_database_options::ADD) {
+ $set_value = c_database_string::ADD;
+ }
+ else if ($set['type'] === e_database_options::DROP) {
+ $set_value = c_database_string::DROP;
+ }
+ else if ($set['type'] === e_database_options::SET) {
+ $set_value = c_database_string::SET;
+ }
+ else {
+ continue;
+ }
+
+ $set_value .= ' ' . $set['option'] . ' ' . $set['value'];
+ $values[] = $set_value;
+ }
+ unset($set);
+ unset($set_value);
+
+ return $value . ' ' . implode(', ', $values);
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql action ALTER COLUMN RESET attribute_option functionality.
+ */
+trait t_database_action_alter_column_reset {
+ protected $action_alter_column_reset;
+
+ /**
+ * Set the RESET attribute option settings.
+ *
+ * @param string|null $column_name
+ * The column name to use.
+ * Set to NULL to disable.
+ * @param string|null $option
+ * (optional) The configuration option.
+ * This is required when $column_name is not NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit reset is returned on error.
+ */
+ public function reset_action_alter_column_reset($column_name, $option = NULL) {
+ if (is_null($column_name)) {
+ $this->action_alter_column_reset = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($option)) {
+ $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);
+ }
+
+ $placeholder_name = $this->add_placeholder($name);
+ if ($placeholder_name->has_error()) {
+ return c_base_return_error::s_false($placeholder_name->get_error());
+ }
+
+ $placeholder_option = $this->add_placeholder($option);
+ if ($placeholder_option->has_error()) {
+ unset($placeholder_name);
+ return c_base_return_error::s_false($placeholder_option->get_error());
+ }
+
+ if (!is_array($this->action_alter_column_reset)) {
+ $this->action_alter_column_reset = [
+ 'column_name' => $placeholder_name,
+ 'values' => [],
+ ];
+ }
+
+ $this->action_alter_column_reset[] = [
+ 'option' => $placeholder_option,
+ ];
+ unset($placeholder_name);
+ unset($placeholder_option);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned settings.
+ *
+ * @param int|null $index
+ * (optional) Get the settings at the specified index.
+ * When NULL, all settings are returned.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array of settings or NULL if not defined.
+ * A single settings is returned if $index is an integer.
+ * NULL with the error bit reset is returned on error.
+ */
+ public function get_action_alter_column_reset($index = NULL) {
+ if (is_null($this->action_alter_column_reset)) {
+ return new c_base_return_null();
+ }
+
+ if (is_null($index)) {
+ if (is_array($this->action_alter_column_reset)) {
+ return c_base_return_array::s_new($this->action_alter_column_reset);
+ }
+ }
+ else {
+ if (is_int($index) && array_key_exists($index, $this->action_alter_column_reset)) {
+ return c_base_return_array::s_new($this->action_alter_column_reset[$index]);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_alter_column_reset[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}' => 'action_alter_column_reset', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_action_alter_column_reset() {
+ $value = c_database_string::ALTER_COLUMN . ' ' . $this->action_alter_column_reset['column_name'] . ' ' . c_database_string::RESET;
+
+ $values = [];
+ foreach ($this->action_alter_column_reset['values'] as $reset) {
+ $values[] = $reset['option'];
+ }
+ unset($reset);
+
+ return $value . ' ' . implode(', ', $values);
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql action ALTER COLUMN SET attribute_option functionality.
+ */
+trait t_database_action_alter_column_set {
+ protected $action_alter_column_set;
+
+ /**
+ * Set the SET attribute option settings.
+ *
+ * @param string|null $column_name
+ * The column name to use.
+ * Set to NULL to disable.
+ * @param string|null $option
+ * (optional) The configuration option.
+ * This is required when $column_name is not NULL.
+ * @param string|null $value
+ * (optional) The configuration options value.
+ * This is required when $column_name is not NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_action_alter_column_set($column_name, $option = NULL, $value = NULL) {
+ if (is_null($column_name)) {
+ $this->action_alter_column_set = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($option)) {
+ $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_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);
+ }
+
+ $placeholder_name = $this->add_placeholder($name);
+ if ($placeholder_name->has_error()) {
+ return c_base_return_error::s_false($placeholder_name->get_error());
+ }
+
+ $placeholder_option = $this->add_placeholder($option);
+ if ($placeholder_option->has_error()) {
+ unset($placeholder_name);
+ return c_base_return_error::s_false($placeholder_option->get_error());
+ }
+
+ $placeholder_value = $this->add_placeholder($value);
+ if ($placeholder_value->has_error()) {
+ unset($placeholder_name);
+ unset($placeholder_option);
+ return c_base_return_error::s_false($placeholder_value->get_error());
+ }
+
+ if (!is_array($this->action_alter_column_set)) {
+ $this->action_alter_column_set = [
+ 'column_name' => $placeholder_name,
+ 'values' => [],
+ ];
+ }
+
+ $this->action_alter_column_set[] = [
+ 'option' => $placeholder_option,
+ 'value' => $placeholder_value,
+ ];
+ unset($placeholder_name);
+ unset($placeholder_option);
+ unset($placeholder_value);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned settings.
+ *
+ * @param int|null $index
+ * (optional) Get the settings at the specified index.
+ * When NULL, all settings are returned.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array of settings or NULL if not defined.
+ * A single settings is returned if $index is an integer.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_action_alter_column_set($index = NULL) {
+ if (is_null($this->action_alter_column_set)) {
+ return new c_base_return_null();
+ }
+
+ if (is_null($index)) {
+ if (is_array($this->action_alter_column_set)) {
+ return c_base_return_array::s_new($this->action_alter_column_set);
+ }
+ }
+ else {
+ if (is_int($index) && array_key_exists($index, $this->action_alter_column_set)) {
+ return c_base_return_array::s_new($this->action_alter_column_set[$index]);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_alter_column_set[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}' => 'action_alter_column_set', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_action_alter_column_set() {
+ $value = c_database_string::ALTER_COLUMN . ' ' . $this->action_alter_column_set['column_name'] . ' ' . c_database_string::SET;
+
+ $values = [];
+ foreach ($this->action_alter_column_set['values'] as $set) {
+ $values[] = $set['option'] . ' = ' . $set['value'];
+ }
+ unset($set);
+
+ return $value . ' ' . implode(', ', $values);
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/enumerations/database_cascade.php');
+
+/**
+ * Provide the sql action DROP COLUMN functionality.
+ */
+trait t_database_action_drop_column {
+ protected $action_drop_column;
+
+ /**
+ * Set the action DROP COLUMN settings.
+ *
+ * @param string|null $column_name
+ * The column name to use.
+ * Set to NULL to disable.
+ * @param bool|null $if_exists
+ * (optional) TRUE for IF EXISTS, FALSE does nothing.
+ * Required when $column_name is not NULL.
+ * Ignored when $column_name is NULL.
+ * @param int|null $cascade
+ * (optional) The cascade type from e_database_cascade.
+ * Ignored when $column_name is NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_action_drop_column($column_name, $if_exists = NULL, $cascade = NULL) {
+ if (is_null($column_name)) {
+ $this->action_drop_column = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($column_name)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'column_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($if_exists) && !is_bool($if_exists)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'if_exists', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ switch ($cascade) {
+ case e_database_cascade::CASCADE:
+ case e_database_cascade::RESTRICT:
+ break;
+
+ default:
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'cascade', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $placeholder_column_name = $this->add_placeholder($column_name);
+ if ($placeholder_column_name->has_error()) {
+ return c_base_return_error::s_false($placeholder_column_name->get_error());
+ }
+
+ $this->action_drop_column = [
+ 'column_name' => $placeholder_column_name,
+ 'if_exists' => $if_exists,
+ 'cascade' => $cascade,
+ ];
+ unset($placeholder_column_name);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned action drop column settings.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing the settings.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_action_drop_column() {
+ if (is_null($this->action_drop_column)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->action_drop_column)) {
+ return c_base_return_array::s_new($this->action_drop_column);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_drop_column', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_action_drop_column() {
+ $value = c_database_string::DROP_COLUMN . ' ' . $this->action_drop_column['column_name'];
+ if ($this->action_drop_column['if_exists']) {
+ $value = c_database_string::IF_EXISTS . ' ' . $value;
+ }
+
+ switch ($this->action_drop_column['cascade']) {
+ case e_database_cascade::CASCADE:
+ $value .= ' ' . c_database_string::CASCADE;
+ break;
+ case e_database_cascade::RESTRICT:
+ $value .= ' ' . c_database_string::RESTRICT;
+ break;
+ }
+
+ return $value;
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/enumerations/database_actions.php');
+
+/**
+ * Provide action_options support for an SQL query.
+ */
+trait t_database_action_options {
+ protected $action_options;
+
+ /**
+ * Set the in action_options.
+ *
+ * @param string|null $type
+ * The option type to use.
+ * Set to NULL to disable.
+ * When NULL, this will remove all values.
+ * @param string|null $option
+ * (optional) The option name to use.
+ * When type is NULL, this is ignored.
+ * Required when $type is not NULL.
+ * @param string|null $value
+ * (optional) The value to associate with the type.
+ * When type is NULL, this is ignored.
+ * Required when $type is not NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_action_options($type, $option = NULL, $value = NULL) {
+ if (is_null($type)) {
+ $this->action_options = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($option)) {
+ $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_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);
+ }
+
+ switch ($type) {
+ case e_database_options::ADD:
+ case e_database_options::DROP:
+ case e_database_options::SET:
+ break;
+ default:
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'schema_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ };
+
+ if (!is_array($this->action_options)) {
+ $this->action_options = [];
+ }
+
+ $placeholder_option = $this->add_placeholder($option);
+ if ($placeholder_option->has_error()) {
+ return c_base_return_error::s_false($placeholder_option->get_error());
+ }
+
+ $placeholder_value = $this->add_placeholder($value);
+ if ($placeholder_value->has_error()) {
+ unset($placeholder_option);
+ return c_base_return_error::s_false($placeholder_value->get_error());
+ }
+
+ $this->action_options[] = [
+ 'type' => $type,
+ 'option' => $placeholder_option,
+ 'value' => $placeholder_value,
+ ];
+ unset($placeholder_option);
+ unset($placeholder_value);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the action_options.
+ *
+ * @param int|null $index
+ * (optional) Get the action_options at the specified index.
+ * When NULL, all action_options are returned.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array of action_options arrays or NULL if not defined.
+ * A single action_options array is returned if $index is an integer.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_action_options($index = NULL) {
+ if (is_null($this->action_options)) {
+ return new c_base_return_null();
+ }
+
+ if (is_null($index)) {
+ if (is_array($this->action_options)) {
+ return c_base_return_array::s_new($this->action_options);
+ }
+ }
+ else {
+ if (is_int($index) && array_key_exists($index, $this->action_options) && is_array($this->action_options[$index])) {
+ return c_base_return_array::s_new($this->action_options[$index]);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_options[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}' => 'action_options', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_action_options() {
+ $value = c_database_string::OPTIONS;
+
+ $values = [];
+ foreach ($this->action_options['values'] as $set) {
+ if ($set['type'] === e_database_options::ADD) {
+ $set_value = c_database_string::ADD;
+ }
+ else if ($set['type'] === e_database_options::DROP) {
+ $set_value = c_database_string::DROP;
+ }
+ else if ($set['type'] === e_database_options::SET) {
+ $set_value = c_database_string::SET;
+ }
+ else {
+ continue;
+ }
+
+ $set_value .= ' ' . $set['option'] . ' ' . $set['value'];
+ $values[] = $set_value;
+ }
+ unset($set);
+ unset($set_value);
+
+ return $value . ' ' . implode(', ', $values);
+ }
+}
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_add_operator_family() {
* 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.
+ * An array containing the add table settings.
* NULL is returned if not set (add table not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_add_table() {
* Get the add/drop user settings.
*
* @return c_base_return_array|c_base_return_null
- * An array of add/drop user settings on success.
+ * An array of add/drop user settings.
* NULL is returned if not set (add/drop user is not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_add_user() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_argument_type() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_as_data_type() {
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+/**
+ * Provide the sql ATTACH PARTITION functionality.
+ */
+trait t_database_attach_partition {
+ protected $attach_partition;
+
+ /**
+ * Set the ATTACH PARTITION settings.
+ *
+ * @param string|null $name
+ * The partition name to use.
+ * Set to NULL to disable.
+ * @param string|null $bound_spec
+ * The bound spec to use.
+ * Required when $name is not NULL.
+ * Ignored when $name is NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_attach_partition($name, $bound_spec = NULL) {
+ if (is_null($name)) {
+ $this->attach_partition = 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_string($bound_spec)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'bound_spec', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $placeholder_name = $this->add_placeholder($name);
+ if ($placeholder_name->has_error()) {
+ return c_base_return_error::s_false($placeholder_name->get_error());
+ }
+
+ $placeholder_bound_spec = $this->add_placeholder($bound_spec);
+ if ($placeholder_bound_spec->has_error()) {
+ unset($placeholder_name);
+ return c_base_return_error::s_false($placeholder_bound_spec->get_error());
+ }
+
+ $this->attach_partition = [
+ 'name' => $placeholder_name,
+ 'bound_spec' => $placeholder_bound_spec,
+ ];
+ unset($placeholder_name);
+ unset($placeholder_bound_spec);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned rename from settings.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing attach partition settings.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_attach_partition() {
+ if (is_null($this->attach_partition)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->attach_partition)) {
+ return c_base_return_array::s_new($this->attach_partition);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'attach_partition', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_attach_partition() {
+ return c_database_string::ATTACH_PARTITION . ' ' . $this->attach_partition['name'] . ' ' . c_database_string::FOR_VALUES . ' ' . $this->attach_partition['bound_spec'];
+ }
+}
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_cache() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_cascade() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_cluster_on() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_column_reset() {
* When NULL, all index attribute option types are returned.
*
* @return c_base_return_array|c_base_return_null
- * An array containing the set index attribute option settings on success.
+ * An array containing the set index attribute option settings.
* NULL is returned if not set (set index attribute option not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_column_set() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_column_set_statistics() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_column_set_storage() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* 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 . ' ' . $this->connection;
+ return c_database_string::CONNECTION . ' ' . strval($this->connection);
}
}
* Get the currently assigned constraint settings.
*
* @return c_base_return_array|c_base_return_null
- * An array of constraint settings on success.
+ * An array of constraint settings.
* NULL is returned if not set (constraint is not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_constraint() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_cycle() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_depends_on_extension() {
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+/**
+ * Provide the sql ATTACH PARTITION functionality.
+ */
+trait t_database_detach_partition {
+ protected $detach_partition;
+
+ /**
+ * Set the ATTACH PARTITION settings.
+ *
+ * @param string|null $name
+ * The partition name to use.
+ * Set to NULL to disable.
+ * @param string|null $bound_spec
+ * The bound spec to use.
+ * Required when $name is not NULL.
+ * Ignored when $name is NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_detach_partition($name, $bound_spec = NULL) {
+ if (is_null($name)) {
+ $this->detach_partition = 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_string($bound_spec)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'bound_spec', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $placeholder_name = $this->add_placeholder($name);
+ if ($placeholder_name->has_error()) {
+ return c_base_return_error::s_false($placeholder_name->get_error());
+ }
+
+ $placeholder_bound_spec = $this->add_placeholder($bound_spec);
+ if ($placeholder_bound_spec->has_error()) {
+ unset($placeholder_name);
+ return c_base_return_error::s_false($placeholder_bound_spec->get_error());
+ }
+
+ $this->detach_partition = [
+ 'name' => $placeholder_name,
+ 'bound_spec' => $placeholder_bound_spec,
+ ];
+ unset($placeholder_name);
+ unset($placeholder_bound_spec);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned rename from settings.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing detach partition settings.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_detach_partition() {
+ if (is_null($this->detach_partition)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->detach_partition)) {
+ return c_base_return_array::s_new($this->detach_partition);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'detach_partition', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_detach_partition() {
+ return c_database_string::ATTACH_PARTITION . ' ' . $this->detach_partition['name'] . ' ' . c_database_string::FOR_VALUES . ' ' . $this->detach_partition['bound_spec'];
+ }
+}
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_disable() {
* 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.
+ * An array containing the add table settings.
* NULL is returned if not set (add table not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_drop_value() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_enable() {
* Get the currently assigned enable trigger settings.
*
* @return c_base_return_array|c_base_return_null
- * An array containing the enable trigger settings on success.
+ * An array containing the enable trigger settings.
* NULL is returned if not set (not to be confused with DISABLE TRIGGER).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_enable_trigger() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_for_role() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_function_action() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_grant() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_grant_option_for() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_group_by() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_handler() {
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql IF EXISTS functionality.
+ */
+trait t_database_if_exists {
+ protected $if_exists;
+
+ /**
+ * Set the IF EXISTS value.
+ *
+ * @param bool|null $if_exists
+ * Set to TRUE for 'IF EXISTS'.
+ * Set to FALSE to not use 'IF EXISTS'.
+ * 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_if_exists($if_exists) {
+ if (is_null($if_exists)) {
+ $this->if_exists = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_bool($if_exists)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'if_exists', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->if_exists = $if_exists;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned set with oids status.
+ *
+ * @return c_base_return_bool|c_base_return_null
+ * TRUE for 'IF EXISTS' and FALSE for not using 'IF EXISTS'.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_if_exists() {
+ if (is_null($this->if_exists)) {
+ return new c_base_return_null();
+ }
+
+ if (is_bool($this->if_exists)) {
+ return c_base_return_bool::s_new($this->if_exists);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'if_exists', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_if_exists() {
+ return $this->if_exists ? c_database_string::IF_EXISTS : NULL;
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql IF NOT EXISTS functionality.
+ */
+trait t_database_if_not_exists {
+ protected $if_not_exists;
+
+ /**
+ * Set the IF NOT EXISTS value.
+ *
+ * @param bool|null $if_not_exists
+ * Set to TRUE for 'IF NOT EXISTS'.
+ * Set to FALSE to not use 'IF NOT EXISTS'.
+ * 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_if_not_exists($if_not_exists) {
+ if (is_null($if_not_exists)) {
+ $this->if_not_exists = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_bool($if_not_exists)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'if_not_exists', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->if_not_exists = $if_not_exists;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned set with oids status.
+ *
+ * @return c_base_return_bool|c_base_return_null
+ * TRUE for 'IF NOT EXISTS' and FALSE for not using 'IF NOT EXISTS'.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_if_not_exists() {
+ if (is_null($this->if_not_exists)) {
+ return new c_base_return_null();
+ }
+
+ if (is_bool($this->if_not_exists)) {
+ return c_base_return_bool::s_new($this->if_not_exists);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'if_not_exists', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_if_not_exists() {
+ return $this->if_not_exists ? c_database_string::IF_NOT_EXISTS : NULL;
+ }
+}
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_in_database() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_in_schema() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_increment_by() {
* Get the currently assigned inherit settings.
*
* @return c_base_return_array|c_base_return_null
- * An array containing the inherit settings on success.
+ * An array containing the inherit settings.
* NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_inherit() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_max_value() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_min_value() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_name() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_no_wait() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_oid() {
* Get the ON operation status.
*
* @return c_base_return_int|c_base_return_null
- * Integer representing the on operation is returned on success.
+ * Integer representing the on operation is returned.
* NULL is returned if undefined.
* FALSE with error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_on() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_on_table() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_operand_left() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_operand_right() {
/**
* Set the in options.
*
- * @param string|null $options_type
+ * @param string|null $type
* The option type to use.
* Set to NULL to disable.
* When NULL, this will remove all values.
- * @param string $value
- * The value to associate with the options_type.
- * When options_type is NULL, this is ignored.
+ * @param string|null $option
+ * (optional) The option name to use.
+ * When type is NULL, this is ignored.
+ * Required when $type is not NULL.
+ * @param string|null $value
+ * (optional) The value to associate with the type.
+ * When type is NULL, this is ignored.
+ * Required when $type is not NULL.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
*/
- public function set_options($options_type, $value) {
- if (is_null($options_type)) {
+ public function set_options($type, $option = NULL, $value = NULL) {
+ if (is_null($type)) {
$this->options = NULL;
return new c_base_return_true();
}
+ if (!is_string($option)) {
+ $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_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);
}
- switch ($options_type) {
+ switch ($type) {
case e_database_options::ADD:
case e_database_options::DROP:
case e_database_options::SET:
$this->options = [];
}
- $placeholder = $this->add_placeholder($value);
- if ($placeholder->has_error()) {
- return c_base_return_error::s_false($placeholder->get_error());
+ $placeholder_option = $this->add_placeholder($option);
+ if ($placeholder_option->has_error()) {
+ return c_base_return_error::s_false($placeholder_option->get_error());
+ }
+
+ $placeholder_value = $this->add_placeholder($value);
+ if ($placeholder_value->has_error()) {
+ unset($placeholder_option);
+ return c_base_return_error::s_false($placeholder_value->get_error());
}
$this->options[] = [
- 'type' => $options_type,
- 'value' => $placeholder,
+ 'type' => $type,
+ 'option' => $placeholder_option,
+ 'value' => $placeholder_value,
];
- unset($placeholder);
+ unset($placeholder_option);
+ unset($placeholder_value);
return new c_base_return_true();
}
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_options() {
- $options = [];
- foreach ($this->options as $options_value) {
- if ($options_value['type'] == e_database_options::ADD) {
- $options[] = c_database_string::ADD . ' ' . $options_value['value'];
+ $value = c_database_string::OPTIONS;
+
+ $values = [];
+ foreach ($this->options['values'] as $set) {
+ if ($set['type'] === e_database_options::ADD) {
+ $set_value = c_database_string::ADD;
}
- else if ($options_value['type'] == e_database_options::DROP) {
- $options[] = c_database_string::DROP . ' ' . $options_value['value'];
+ else if ($set['type'] === e_database_options::DROP) {
+ $set_value = c_database_string::DROP;
}
- else if ($options_value['type'] == e_database_options::SET) {
- $options[] = c_database_string::SET . ' ' . $options_value['value'];
+ else if ($set['type'] === e_database_options::SET) {
+ $set_value = c_database_string::SET;
}
+ else {
+ continue;
+ }
+
+ $set_value .= ' ' . $set['option'] . ' ' . $set['value'];
+ $values[] = $set_value;
}
- unset($options_value);
+ unset($set);
+ unset($set_value);
- return empty($options) ? NULL : c_database_string::OPTIONS . ' ' . implode(', ', $options);
+ return $value . ' ' . implode(', ', $values);
}
}
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_order_by() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_owned_by() {
* Get the currently assigned owner to settings.
*
* @return c_base_return_array|c_base_return_null
- * An array containing the owner to settings on success.
+ * An array containing the owner to settings.
* NULL without error bit set is returned if not assigned.
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_owner_to() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_privilege() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_procedural() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_refresh_publication() {
* Get the currently assigned rename from settings.
*
* @return c_base_return_array|c_base_return_null
- * An array containing rename from settings on success.
+ * An array containing rename from settings.
* NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
}
if (is_array($this->rename_column)) {
- return c_base_return_array::s_new($this->rename_column['from']);
+ return c_base_return_array::s_new($this->rename_column);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'rename_column', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_rename_column() {
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+/**
+ * Provide the sql RENAME CONSTRAINT functionality.
+ */
+trait t_database_rename_constraint {
+ protected $rename_constraint;
+
+ /**
+ * Set the RENAME CONSTRAINT settings.
+ *
+ * @param string|null $from_name
+ * The constraint name to rename from.
+ * Set to NULL to disable.
+ * @param string|null $to_name
+ * The constraint name to rename to.
+ * Required when $from_name is not NULL.
+ * Ignored when $from_name is NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_rename_constraint($from_name, $to_name = NULL) {
+ if (is_null($from_name)) {
+ $this->rename_constraint = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($from_name)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'from_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_string($to_name)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'to_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $placeholder_from = $this->add_placeholder($from_name);
+ if ($placeholder_from->has_error()) {
+ return c_base_return_error::s_false($placeholder_from->get_error());
+ }
+
+ $placeholder_to = $this->add_placeholder($to_name);
+ if ($placeholder_to->has_error()) {
+ unset($placeholder_from);
+ return c_base_return_error::s_false($placeholder_to->get_error());
+ }
+
+ $this->rename_constraint = [
+ 'from' => $placeholder_from,
+ 'to' => $placeholder_to,
+ ];
+ unset($placeholder_from);
+ unset($placeholder_to);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned rename from settings.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing rename from settings.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_rename_constraint() {
+ if (is_null($this->rename_constraint)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->rename_constraint)) {
+ return c_base_return_array::s_new($this->rename_constraint);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'rename_constraint', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_rename_constraint() {
+ return c_database_string::RENAME_CONSTRAINT . ' ' . $this->rename_constraint['from'] . ' ' . c_database_string::TO . ' ' . $this->rename_constraint['to'];
+ }
+}
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_rename_to() {
* Get the currently assigned reset configuration_parameter settings.
*
* @return c_base_return_array|c_base_return_null
- * An array containing reset settings on success.
+ * An array containing reset settings.
* NULL is returned if not set (reset tablespace is not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_reset_configuration_parameter() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_reset_storage_parameter() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_restart_with() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_restrict() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_role_specification() {
}
$set['value'] = $placeholder;
- unset($placeholder);
}
+ unset($placeholder);
$this->set_configuration_parameter = $configuration_parameter;
unset($configuration_parameter);
* Get the currently assigned set configuration parameter settings.
*
* @return c_base_return_array|c_base_return_null
- * An array containing set configuration parameter settings on success.
+ * An array containing set configuration parameter settings.
* NULL is returned if not set (set tablespace is not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_configuration_parameter() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_operator() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_publication_name() {
* 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.
+ * An array containing the set publication parameter settings.
* NULL is returned if not set (publication parameter not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_publication_parameter() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_schema() {
* 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.
+ * An array containing the set index storage parameter settings.
* NULL is returned if not set (set index storage parameter not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_storage_parameter() {
* 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.
+ * An array containing the add table settings.
* NULL is returned if not set (add table not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_table() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_tablespace() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_with_oids() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_without_cluster() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_start_with() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_to_role() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_using_expression() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_using_index_method() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_validator() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_version() {
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql * functionality.
+ */
+trait t_database_wildcard {
+ protected $wildcard;
+
+ /**
+ * Set the * value.
+ *
+ * @param bool|null $wildcard
+ * Set to TRUE for '*'.
+ * Set to FALSE to not 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_wildcard($wildcard) {
+ if (is_null($wildcard)) {
+ $this->wildcard = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_bool($wildcard)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'wildcard', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->wildcard = $wildcard;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned set with oids status.
+ *
+ * @return c_base_return_bool|c_base_return_null
+ * TRUE for '*' and FALSE for not using '*'.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_wildcard() {
+ if (is_null($this->wildcard)) {
+ return new c_base_return_null();
+ }
+
+ if (is_bool($this->wildcard)) {
+ return c_base_return_bool::s_new($this->wildcard);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'wildcard', ':{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.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_wildcard() {
+ return $this->wildcard ? '*' : NULL;
+ }
+}
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_with_check_expression() {
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_with_grant_option() {
* 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.
+ * An array containing the with publication option settings.
* NULL is returned if not set (with publication option not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_with_publication_option() {
* 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.
+ * An array containing the with refresh option settings.
* NULL is returned if not set (with refresh option not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_with_refresh_option() {
* Get the with role option settings.
*
* @return c_base_return_array|c_base_return_null
- * An array of with role option settings on success.
+ * An array of with role option settings.
* NULL is returned if not set (with role option is not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_with_role_option() {
* 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.
+ * An array containing the set index storage parameter settings.
* NULL is returned if not set (set index storage parameter not to be used).
* NULL with the error bit set is returned on error.
*/
* As an internal trait method, the caller is expected to perform any appropriate validation.
*
* @return string|null
- * A string is returned on success.
+ * A string is returned.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_with_storage_parameter() {