require_once('common/base/classes/base_return.php');
require_once('common/database/enumerations/database_reset.php');
-require_once('common/database/enumerations/database_set.php');
+require_once('common/database/enumerations/database_set_configuration_parameter.php');
require_once('common/database/classes/database_query.php');
require_once('common/database/classes/database_string.php');
require_once('common/database/traits/database_rename_to.php');
require_once('common/database/traits/database_owner_to.php');
require_once('common/database/traits/database_set_tablespace.php');
-require_once('common/database/traits/database_set.php');
+require_once('common/database/traits/database_set_configuration_parameter.php');
require_once('common/database/traits/database_reset.php');
/**
use t_database_name;
use t_database_rename_to;
use t_database_owner_to;
- use t_database_set;
+ use t_database_set_configuration_parameter;
use t_database_set_tablespace;
use t_database_reset;
public function __construct() {
parent::__construct();
- $this->name = NULL;
- $this->rename_to = NULL;
- $this->owner_to = NULL;
- $this->set = NULL;
- $this->set_tablespace = NULL;
- $this->reset = NULL;
+ $this->name = NULL;
+ $this->rename_to = NULL;
+ $this->owner_to = NULL;
+ $this->set_configuration_parameter = NULL;
+ $this->set_tablespace = NULL;
+ $this->reset = NULL;
// TODO: it may be better (and more consistent) to convert option into a trait, just like all of the others.
$this->option = NULL;
unset($this->name);
unset($this->rename_to);
unset($this->owner_to);
- unset($this->set);
+ unset($this->set_configuration_parameter);
unset($this->set_tablespace);
unset($this->reset);
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
- * FALSE with error bit set is returned on error.
+ * FALSE with error bit set_configuration_parameter is returned on error.
*/
public function set_option($option) {
if (is_null($option)) {
*
* @return c_database_argument_database_option|c_base_return_null
* The assigned option or NULL if not defined.
- * NULL with the error bit set is returned on error.
+ * NULL with the error bit set_configuration_parameter is returned on error.
*/
public function get_option() {
if (is_null($this->option)) {
else if (isset($this->set_tablespace)) {
$value .= $this->p_do_build_set_tablespace();
}
- else if (is_array($this->set)) {
- $value .= $this->p_do_build_set();
+ else if (is_array($this->set_configuration_parameter)) {
+ $value .= $this->p_do_build_set_configuration_parameter();
}
else if (is_array($this->reset)) {
$value .= $this->p_do_build_reset();
require_once('common/database/traits/database_rename_to.php');
require_once('common/database/traits/database_reset.php');
require_once('common/database/traits/database_role_specification.php');
-require_once('common/database/traits/database_set.php');
+require_once('common/database/traits/database_set_configuration_parameter.php');
require_once('common/database/traits/database_with_role_option.php');
use t_database_reset;
use t_database_role_option;
use t_database_role_specification;
- use t_database_set;
+ use t_database_set_configuration_parameter;
protected const p_QUERY_COMMAND = 'alter role';
public function __construct() {
parent::__construct();
- $this->in_database = NULL;
- $this->name = NULL;
- $this->rename = NULL;
- $this->reset = NULL;
- $this->role_specification = NULL;
- $this->set = NULL;
- $this->with_role_option = NULL;
+ $this->in_database = NULL;
+ $this->name = NULL;
+ $this->rename = NULL;
+ $this->reset = NULL;
+ $this->role_specification = NULL;
+ $this->set_configuration_parameter = NULL;
+ $this->with_role_option = NULL;
}
/**
unset($this->rename);
unset($this->reset);
unset($this->role_specification);
- unset($this->set);
+ unset($this->set_configuration_parameter);
unset($this->with_role_option);
parent::__destruct();
$value .= ' ' . $this->p_do_build_in_database();
}
- if (isset($this->set)) {
- $value .= ' ' . $this->p_do_build_set();
+ if (isset($this->set_configuration_parameter)) {
+ $value .= ' ' . $this->p_do_build_set_configuration_parameter();
}
else if (isset($this->reset)) {
$value .= ' ' . $this->p_do_build_reset();
require_once('common/database/traits/database_owner_to.php');
require_once('common/database/traits/database_refresh_publication.php');
require_once('common/database/traits/database_rename_to.php');
-require_once('common/database/traits/database_set.php');
+require_once('common/database/traits/database_set_configuration_parameter.php');
require_once('common/database/traits/database_set_publication_name.php');
require_once('common/database/traits/database_set_schema.php');
require_once('common/database/traits/database_with_publication_option.php');
use t_database_owner_to;
use t_database_refresh_publication;
use t_database_rename_to;
- use t_database_set;
+ use t_database_set_configuration_parameter;
use t_database_set_publication_name;
use t_database_set_schema;
use t_database_with_publication_option;
public function __construct() {
parent::__construct();
- $this->connection = NULL;
- $this->disable = NULL;
- $this->enable = NULL;
- $this->name = NULL;
- $this->owner_to = NULL;
- $this->refresh_publication = NULL;
- $this->rename_to = NULL;
- $this->set = NULL;
- $this->set_publication_name = NULL;
- $this->set_schema = NULL;
- $this->with_publication_option = NULL;
- $this->with_refresh_option = NULL;
+ $this->connection = NULL;
+ $this->disable = NULL;
+ $this->enable = NULL;
+ $this->name = NULL;
+ $this->owner_to = NULL;
+ $this->refresh_publication = NULL;
+ $this->rename_to = NULL;
+ $this->set_configuration_parameter = NULL;
+ $this->set_publication_name = NULL;
+ $this->set_schema = NULL;
+ $this->with_publication_option = NULL;
+ $this->with_refresh_option = NULL;
}
/**
unset($this->owner_to);
unset($this->refresh_publication);
unset($this->rename_to);
- unset($this->set);
+ unset($this->set_configuration_parameter);
unset($this->set_publication_name);
unset($this->set_schema);
unset($this->with_publication_option);
else if (isset($this->disable)) {
$value .= ' ' . $this->p_do_build_disable();
}
- else if (isset($this->set)) {
- $value .= ' ' . $this->p_do_build_set();
+ else if (isset($this->set_configuration_parameter)) {
+ $value .= ' ' . $this->p_do_build_set_configuration_parameter();
}
else if (isset($this->owner_to)) {
$value .= ' ' . $this->p_do_build_owner_to();
public const TRUNCATE = 'truncate';
public const TYPE = 'type';
public const TO = 'to';
+ public const TO_DEFAULT = 'to default';
public const UNSAFE = 'unsafe';
public const UPDATE = 'update';
public const USAGE = 'usage';
class e_database_set {
public const NONE = 0;
public const TO = 1;
- public const EQUAL = 2;
- public const FROM_CURRENT = 3;
+ public const TO_DEFAULT = 2;
+ public const EQUAL = 3;
+ public const FROM_CURRENT = 4;
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_connection() {
- return c_database_string::CONNECTION . ' ' . strval($this->connection);
+ return c_database_string::CONNECTION . ' ' . $this->connection;
}
}
/**
* Provide the sql SET functionality.
*/
-trait t_database_set {
- protected $set;
+trait t_database_set_configuration_parameter {
+ protected $set_configuration_parameter;
/**
- * Set the SET settings.
+ * Set the SET configuation parameter settings.
*
- * @param int|null $set
+ * @param int|null $type
* The SET code to assign.
* Should be one of: e_database_set.
* Set to NULL to disable.
* TRUE on success, FALSE otherwise.
* FALSE with the error bit set is returned on error.
*/
- public function set_set($set, $parameter = NULL, $value = NULL) {
- if (is_null($set)) {
- $this->set = NULL;
+ public function set_set_configuration_parameter($type, $parameter = NULL, $value = NULL) {
+ if (is_null($type)) {
+ $this->set_configuration_parameter = NULL;
return new c_base_return_true();
}
- if (!is_int($set)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'set', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ if (!is_int($type)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
- if ($set === e_database_set::TO || $set === e_database_set::EQUAL) {
+ if ($type === e_database_set::TO || $type === e_database_set::EQUAL) {
if (!is_string($parameter)) {
$error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
return c_base_return_error::s_false($placeholder->get_error());
}
- $set = [
- 'type' => $set,
+ $configuration_parameter = [
+ 'type' => $type,
'parameter' => $placeholder,
'value' => NULL,
];
if (is_string($value)) {
$placeholder = $this->add_placeholder($value);
if ($placeholder->has_error()) {
- unset($set);
+ unset($configuration_parameter);
return c_base_return_error::s_false($placeholder->get_error());
}
unset($placeholder);
}
- $this->set = $set;
- unset($set);
+ $this->set_configuration_parameter = $configuration_parameter;
+ unset($configuration_parameter);
return new c_base_return_true();
}
- else if ($set == e_database_set::FROM_CURRENT) {
- $this->set = [
- 'type' => $set,
+ else if ($type == e_database_set::FROM_CURRENT) {
+ $this->set_configuration_parameter = [
+ 'type' => $type,
'parameter' => NULL,
'value' => NULL,
];
}
/**
- * Get the currently assigned set settings.
+ * Get the currently assigned set configuration parameter settings.
*
* @return c_base_return_array|c_base_return_null
- * An array containing set settings on success.
+ * An array containing set configuration parameter settings on success.
* NULL is returned if not set (set tablespace is not to be used).
* NULL with the error bit set is returned on error.
*/
- public function get_set() {
- if (is_null($this->set)) {
+ public function get_set_configuration_parameter() {
+ if (is_null($this->set_configuration_parameter)) {
return new c_base_return_null();
}
- if (is_array($this->set)) {
- return c_base_return_array::s_new($this->set);
+ if (is_array($this->set_configuration_parameter)) {
+ return c_base_return_array::s_new($this->set_configuration_parameter);
}
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_configuration_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_null($error);
}
* A string is returned on success.
* NULL is returned if there is nothing to process or there is an error.
*/
- protected function p_do_build_set() {
+ protected function p_do_build_set_configuration_parameter() {
$value = NULL;
- if ($this->set['type'] === e_database_set::TO) {
- $value = c_database_string::SET . ' ' . $this->set['parameter'] . ' ' . c_database_string::TO . ' ';
- if (is_null($this->set['value'])) {
+ if ($this->set_configuration_parameter['type'] === e_database_set::TO) {
+ $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' ' . c_database_string::TO . ' ';
+ if (is_null($this->set_configuration_parameter['value'])) {
$value .= c_database_string::DEFAULT;
}
else {
- $value = $this->set['value'];
+ $value = $this->set_configuration_parameter['value'];
}
}
- else if ($this->set['type'] === e_database_set::EQUAL) {
- $value = c_database_string::SET . ' ' . $this->set['parameter'] . ' = ';
- if (is_null($this->set['value'])) {
+ else if ($this->set_configuration_parameter['type'] === e_database_set::EQUAL) {
+ $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' = ';
+ if (is_null($this->set_configuration_parameter['value'])) {
$value .= c_database_string::DEFAULT;
}
- else if (isset($this->set['parameter']) && isset($this->set['value'])) {
- $value .= $this->set['value'];
+ else if (isset($this->set_configuration_parameter['parameter']) && isset($this->set_configuration_parameter['value'])) {
+ $value .= $this->set_configuration_parameter['value'];
}
}
- else if ($this->set['type'] == e_database_set::FROM_CURRENT) {
- $value = c_database_string::SET . ' ' . $this->set['parameter'] . ' = ' . c_database_string::FROM_CURRENT;
+ else if ($this->set_configuration_parameter['type'] == e_database_set::FROM_CURRENT) {
+ $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' = ' . c_database_string::FROM_CURRENT;
+ }
+ else if ($this->set_configuration_parameter['type'] == e_database_set::TO_DEFAULT) {
+ $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' ' . c_database_string::TO_DEFAULT;
}
return $value;