*
* When no argument mode is specified, then a wildcard * is auto-provided for the aggregate_signature parameter.
*
+ * @todo: review this implementation, may be outdated.
+ *
* @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html
*/
class c_database_alter_aggregate extends c_database_query {
/**
* Get the aggregate signatures.
*
- * @param int|null $index
- * (optional) Get the argument signature at the specified index.
- * When NULL, all argument signatures are returned.
- *
- * @return c_database_argument_aggregate_signature|c_base_return_array|c_base_return_null
+ * @return c_base_return_array|c_base_return_null
* An array of aggregate signatures or NULL if not defined.
- * A single aggregate signature is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_aggregate_signature($index = NULL) {
+ public function get_aggregate_signature() {
if (is_null($this->aggregate_signatures)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->aggregate_signatures)) {
- return c_base_return_array::s_new($this->aggregate_signatures);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->aggregate_signatures) && $this->aggregate_signatures[$index] instanceof c_database_argument_aggregate_signature) {
- return clone($this->aggregate_signatures[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'aggregate_signatures[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->aggregate_signatures)) {
+ return c_base_return_array::s_new($this->aggregate_signatures);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'aggregate_signatures', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* Get the total aggregate signatures.
*
- * @param int|null $index
- * (optional) Get the aggregate signature at the specified index.
- * When NULL, all aggregate signatures are returned.
- *
* @return c_base_return_int
* The total number of aggregate signatures.
* 0 with the error bit set is returned on error.
*/
- public function get_aggregate_signature_count($index = NULL) {
+ public function get_aggregate_signature_count() {
if (is_null($this->aggregate_signatures)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- return new c_base_return_int(0);
- }
- else if (is_array($this->aggregate_signatures)) {
+ if (is_array($this->aggregate_signatures)) {
return new c_base_return_int(count($this->aggregate_signatures));
}
/**
* Get the order by aggregate signatures.
*
- * @param int|null $index
- * (optional) Get the argument signature at the specified index.
- * When NULL, all argument signatures are returned.
- *
- * @return c_database_argument_aggregate_signature|c_base_return_array|c_base_return_null
+ * @return c_base_return_array|c_base_return_null
* An array of order by aggregate signatures or NULL if not defined.
- * A single order by aggregate signature is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_order_by_signature($index = NULL) {
+ public function get_order_by_signature() {
if (is_null($this->order_by_signatures)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->order_by_signatures)) {
- return c_base_return_array::s_new($this->order_by_signatures);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->order_by_signatures) && $this->order_by_signatures[$index] instanceof c_database_argument_aggregate_signature_base) {
- return clone($this->order_by_signatures[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'order_by_signatures[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->order_by_signatures)) {
+ return c_base_return_array::s_new($this->order_by_signatures);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'order_by_signatures', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
* The total number of aggregate signatures.
* 0 with the error bit set is returned on error.
*/
- public function get_order_by_signature_count($index = NULL) {
+ public function get_order_by_signature_count() {
if (is_null($this->order_by_signatures)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- return new c_base_return_int(0);
- }
- else if (is_array($this->aggregate_signatures)) {
+ if (is_array($this->aggregate_signatures)) {
return new c_base_return_int(count($this->aggregate_signatures));
}
$value .= is_null($value) ? '' : ' ';
$value .= $this->p_do_build_grant();
- if ($this->grant === e_database_action::ACTION_REVOKE) {
+ if ($this->grant === e_database_action_deprecated::ACTION_REVOKE) {
if ($this->grant_option_for) {
$value .= ' ' . $this->p_do_build_grant_option_for();
}
$value .= ' ' . $this->p_do_build_on();
}
- if ($this->grant === e_database_action::GRANT) {
+ if ($this->grant === e_database_action_deprecated::GRANT) {
$value .= ' ' . c_database_string::TO;
}
- else if ($this->grant === e_database_action::REVOKE) {
+ else if ($this->grant === e_database_action_deprecated::REVOKE) {
$value .= ' ' . c_database_string::FROM;
}
$value .= ' ' . $this->p_do_build_to_role();
}
- if ($this->grant === e_database_action::GRANT) {
+ if ($this->grant === e_database_action_deprecated::GRANT) {
if ($this->with_grant_option) {
$value .= ' ' . $this->p_do_build_with_grant_option();
}
}
- else if ($this->grant === e_database_action::REVOKE) {
+ else if ($this->grant === e_database_action_deprecated::REVOKE) {
if (is_int($this->cascade)) {
$value .= ' ' . $this->p_do_build_cascade();
}
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
-require_once('common/database/enumerations/database_action.php');
+require_once('common/database/enumerations/database_action_deprecated.php');
require_once('common/database/enumerations/database_cascade.php');
require_once('common/database/classes/database_query.php');
require_once('common/database/traits/database_owner_to.php');
require_once('common/database/traits/database_rename_to.php');
require_once('common/database/traits/database_set_schema.php');
-require_once('common/database/traits/database_action.php');
+require_once('common/database/traits/database_action_deprecated.php');
/**
* The class for building and returning a Postgresql ALTER DOMAIN query string.
*
* @see: https://www.postgresql.org/docs/current/static/sql-alterdomain.html
*/
-class c_database_alter_coalation extends c_database_query {
+class c_database_alter_domain extends c_database_query {
use t_database_name;
use t_database_owner_to;
use t_database_rename_to;
use t_database_set_schema;
- use t_database_action;
+ use t_database_action_deprecated;
protected const p_QUERY_COMMAND = 'alter domain';
$value = $this->p_do_build_name() . ' ';
switch ($this->action) {
- case e_database_action::ADD:
+ case e_database_action_deprecated::ADD:
if (!is_array($this->constraint)) {
unset($value);
return new c_base_return_false();
}
break;
- case e_database_action::DROP:
+ case e_database_action_deprecated::DROP:
$value .= c_database_string::DROP;
if ($this->property === e_database_property::NOT_NULL) {
$value .= ' ' . c_database_string::NOT_NULL;
}
break;
- case e_database_action::DROP_CONSTRAINT:
+ case e_database_action_deprecated::DROP_CONSTRAINT:
if (!is_array($this->constraint['name'])) {
unset($value);
return new c_base_return_false();
}
break;
- case e_database_action::DROP_DEFAULT:
+ case e_database_action_deprecated::DROP_DEFAULT:
$value .= c_database_string::DROP_DEFAULT;
break;
- case e_database_action::OWNER_TO:
+ case e_database_action_deprecated::OWNER_TO:
if (!isset($this->owner_to)) {
unset($value);
return new c_base_return_false();
$value .= $this->p_do_build_owner_to();
break;
- case e_database_action::RENAME_CONSTRAINT:
+ case e_database_action_deprecated::RENAME_CONSTRAINT:
if (!isset($this->constraint['name']) || !isset($this->constraint['name_new'])) {
unset($value);
return new c_base_return_false();
$value .= c_database_string::RENAME_CONSTRAINT . ' ' . $this->constraint['name'] . ' ' . c_database_string::TO . ' ' . $this->constraint['name_new'];
break;
- case e_database_action::RENAME_TO:
+ case e_database_action_deprecated::RENAME_TO:
if (!isset($this->rename_to)) {
unset($value);
return new c_base_return_false();
$value .= $this->p_do_build_rename_to();
break;
- case e_database_action::SET:
+ case e_database_action_deprecated::SET:
$value = c_database_string::SET;
if ($this->property === e_database_property::NOT_NULL) {
$value .= ' ' . c_database_string::NOT_NULL;
}
break;
- case e_database_action::SET_DEFAULT:
+ case e_database_action_deprecated::SET_DEFAULT:
if (!isset($this->expression)) {
unset($value);
return new c_base_return_false();
$value .= c_database_string::SET_DEFAULT . ' ' . $this->expression;
break;
- case e_database_action::SET_SCHEMA:
+ case e_database_action_deprecated::SET_SCHEMA:
if (!isset($this->set_schema)) {
unset($value);
return new c_base_return_false();
$value .= $this->p_do_build_set_schema();
break;
- case e_database_action::VALIDATE_CONSTRAINT:
+ case e_database_action_deprecated::VALIDATE_CONSTRAINT:
if (!is_array($this->constraint)) {
unset($value);
return new c_base_return_false();
require_once('common/database/classes/database_query.php');
-require_once('common/database/traits/database_action.php');
+require_once('common/database/traits/database_action_deprecated.php');
require_once('common/database/traits/database_name.php');
require_once('common/database/traits/database_owner_to.php');
require_once('common/database/traits/database_rename_to.php');
* @see: https://www.postgresql.org/docs/current/static/sql-altereventtrigger.html
*/
class c_database_alter_coalation extends c_database_query {
- use t_database_action;
- use t_database_action_property;
+ use t_database_action_deprecated;
+ use t_database_action_property_deprecated;
use t_database_name;
use t_database_owner_to;
use t_database_rename_to;
$value = $this->p_do_build_name() . ' ';
switch($this->action) {
- case e_database_action::DISABLE:
+ case e_database_action_deprecated::DISABLE:
$value .= c_database_string::DISABLE;
break;
- case e_database_action::ENABLE:
+ case e_database_action_deprecated::ENABLE:
$value .= c_database_string::ENABLE;
if ($this->action_property === e_database_property::REPLICA) {
$value .= ' ' . c_database_string::REPLICA;
return new c_base_return_false();
}
break;
- case e_database_action::OWNER_TO:
+ case e_database_action_deprecated::OWNER_TO:
if (isset($this->owner_to)) {
$value .= $this->p_do_build_owner_to();
}
return new c_base_return_false();
}
break;
- case e_database_action::RENAME_TO:
+ case e_database_action_deprecated::RENAME_TO:
if (isset($this->rename_to)) {
$value .= $this->p_do_build_rename_to();
}
require_once('common/database/classes/database_query.php');
require_once('common/database/classes/database_member_object.php');
-require_once('common/database/traits/database_action.php');
+require_once('common/database/traits/database_action_deprecated.php');
require_once('common/database/traits/database_name.php');
* @see: https://www.postgresql.org/docs/current/static/sql-alterextension.html
*/
class c_database_alter_extension extends c_database_query {
- use t_database_action;
+ use t_database_action_deprecated;
use t_database_action_parameter;
use t_database_name;
$value = $this->p_do_build_name() . ' ';
switch($this->action) {
- case e_database_action::UPDATE:
+ case e_database_action_deprecated::UPDATE:
$value .= c_database_string::UPDATE;
if (isset($this->action_parameter)) {
$value .= ' ' . c_database_string::TO . ' ' . $this->action_parameter;
return new c_base_return_false();
}
break;
- case e_database_action::SET_SCHEMA:
+ case e_database_action_deprecated::SET_SCHEMA:
if (isset($this->set_schema)) {
$value = $this->p_do_build_set_schema();
}
return new c_base_return_false();
}
break;
- case e_database_action::ADD:
+ case e_database_action_deprecated::ADD:
$value .= c_database_string::ADD;
if ($this->action_parameter instanceof c_database_member_object && $this->action_parameter->do_build() instanceof c_base_return_true) {
$value .= ' ' . $this->action_parameter->get_value();
return new c_base_return_false();
}
break;
- case e_database_action::DROP:
+ case e_database_action_deprecated::DROP:
$value .= c_database_string::DROP;
if ($this->action_parameter instanceof c_database_member_object) {
if ($this->action_parameter->do_build() instanceof c_base_return_true) {
// @fixme: rewrite this.
$value = NULL;
- if ($this->action === e_database_action::OWNER_TO) {
+ if ($this->action === e_database_action_deprecated::OWNER_TO) {
if (isset($this->owner_to)) {
$value = $this->p_do_build_owner_to();
}
return new c_base_return_false();
}
}
- else if ($this->action === e_database_action::RENAME_TO) {
+ else if ($this->action === e_database_action_deprecated::RENAME_TO) {
if (isset($this->rename_to)) {
$value = $this->p_do_build_rename_to();
}
require_once('common/database/classes/database_query.php');
+require_once('common/database/traits/database_in_database.php');
+require_once('common/database/traits/database_name.php');
+require_once('common/database/traits/database_rename_to.php');
+require_once('common/database/traits/database_reset_configuration_parameter.php');
+require_once('common/database/traits/database_role_specification.php');
+require_once('common/database/traits/database_set_configuration_parameter.php');
+require_once('common/database/traits/database_with_role_option.php');
/**
- * The class for building and returning a Postgresql ALTER COALATION query string.
+ * The class for building and returning a Postgresql ALTER USER query string.
*
- * @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html
+ * @see: https://www.postgresql.org/docs/current/static/sql-alteruser.html
*/
-class c_database_alter_coalation extends c_database_query {
- protected const p_QUERY_COMMAND = 'alter coalation';
+class c_database_alter_user extends c_database_query {
+ use t_database_in_database;
+ use t_database_name;
+ use t_database_rename_to;
+ use t_database_reset_configuration_parameter;
+ use t_database_role_specification;
+ use t_database_set_configuration_parameter;
+ use t_database_with_role_option;
+
+ protected const p_QUERY_COMMAND = 'alter user';
/**
*/
public function __construct() {
parent::__construct();
+
+ $this->in_database = NULL;
+ $this->name = NULL;
+ $this->rename_to = NULL;
+ $this->reset_configuration_parameter = NULL;
+ $this->role_specification = NULL;
+ $this->set_configuration_parameter = NULL;
+ $this->with_role_option = NULL;
+
}
/**
* Class destructor.
*/
public function __destruct() {
+ unset($this->in_database);
+ unset($this->name);
+ unset($this->rename_to);
+ unset($this->reset_configuration_parameter);
+ unset($this->role_specification);
+ unset($this->set_configuration_parameter);
+ unset($this->with_role_option);
+
parent::__destruct();
}
* Implements do_build().
*/
public function do_build() {
- if (is_null($this->name)) {
+ if (isset($this->name)) {
+ if (isset($this->rename_to)) {
+ $this->value = static::p_QUERY_COMMAND;
+ $this->value .= ' ' . $this->p_do_build_name();
+ $this->value .= ' ' . $this->p_do_build_rename_to();
+ return new c_base_return_true();
+ }
+
+ return new c_base_return_false();
+ }
+ else if (!isset($this->role_specification)) {
return new c_base_return_false();
}
- $value = $this->p_do_build_name();
+ $value = $this->p_do_build_role_specification();
+
+ if (isset($this->with_role_option)) {
+ $value .= ' ' . $this->p_do_build_with_role_option();
+ }
+ else if (isset($this->set_configuration_parameter)) {
+ $value .= ' ' . $this->p_do_build_set_configuration_parameter();
+ }
+ else if (isset($this->reset_configuration_parameter)) {
+ $value .= ' ' . $this->p_do_build_reset_configuration_parameter();
+ }
+ else {
+ return new c_base_return_false();
+ }
$this->value = static::p_QUERY_COMMAND;
$this->value .= ' ' . $value;
require_once('common/database/classes/database_query.php');
+require_once('common/database/traits/database_server_name.php');
+require_once('common/database/traits/database_server_options.php');
+require_once('common/database/traits/database_user_name.php');
/**
- * The class for building and returning a Postgresql ALTER COALATION query string.
+ * The class for building and returning a Postgresql ALTER USER MAPPING query string.
*
- * @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html
+ * @see: https://www.postgresql.org/docs/current/static/sql-alterusermapping.html
*/
-class c_database_alter_coalation extends c_database_query {
- protected const p_QUERY_COMMAND = 'alter coalation';
+class c_database_alter_user_mapping extends c_database_query {
+ use t_database_server_name;
+ use t_database_server_options;
+ use t_database_user_name;
+ protected const p_QUERY_COMMAND = 'alter user mapping for';
/**
* Class constructor.
*/
public function __construct() {
parent::__construct();
+
+ $this->server_name = NULL;
+ $this->server_options = NULL;
+ $this->user_name = NULL;
}
/**
* Class destructor.
*/
public function __destruct() {
+ unset($this->server_name);
+ unset($this->server_options);
+ unset($this->user_name);
+
parent::__destruct();
}
* Implements do_build().
*/
public function do_build() {
- if (is_null($this->name)) {
+ if (!isset($this->user_name) || !isset($this->server_name) || !isset($this->server_options)) {
return new c_base_return_false();
}
- $value = $this->p_do_build_name();
-
$this->value = static::p_QUERY_COMMAND;
- $this->value .= ' ' . $value;
+ $this->value .= ' ' . $this->p_do_build_user_name();
+ $this->value .= ' ' . $this->p_do_build_server_name();
+ $this->value .= ' ' . $this->p_do_build_server_options();
unset($value);
return new c_base_return_true();
require_once('common/database/classes/database_query.php');
-require_once('common/database/traits/database_action.php');
+require_once('common/database/traits/database_action_deprecated.php');
require_once('common/database/traits/database_name.php');
/**
* @see: https://www.postgresql.org/docs/current/static/sql-alterextension.html
*/
class c_database_member_object extends c_database_query {
- use t_database_action;
+ use t_database_action_deprecated;
use t_database_action_parameter;
use t_database_name;
class c_database_string {
public const ACCESS_METHOD = 'access method';
public const ADD = 'add';
+ public const ADD_ATTRIBUTE = 'add attribute';
public const ADD_COLUMN = 'add column';
public const ADD_TABLE = 'add table';
public const ADD_VALUE = 'add value';
public const ALL = 'all';
public const ALLOW_CONNECTIONS = 'allow_connections';
public const ALTER = 'alter';
+ public const ALTER_ATTRIBUTE = 'alter attribute';
public const ALTER_CONSTRAINT = 'alter constraint';
public const AS = 'as';
public const ASCEND = 'asc';
public const DISABLE_TRIGGER = 'disable trigger';
public const DOMAIN = 'domain';
public const DROP = 'drop';
+ public const DROP_ATTRIBUTE = 'drop attribute';
public const DROP_CONSTRAINT = 'drop constraint';
public const DROP_DEFAULT = 'drop default';
public const DROP_MAPPING = 'drop mapping';
public const FALSE = 'false';
public const FASTUPDATE = 'fastupdate';
public const FILLFACTOR = 'fillfactor';
+ public const FOR = 'for';
public const FOREIGN_DATA_WRAPPER = 'foreign data wrapper';
public const FOREIGN_TABLE = 'foreign table';
- public const FOR = 'for';
public const FOR_ORDER_BY = 'for order by';
public const FOR_ROLE = 'for role';
public const FOR_SEARCH = 'for search';
public const REFRESH = 'refresh';
public const REFRESH_PUBLICATION = 'refresh publication';
public const REFRESH_VERSION = 'refresh version';
- public const RENAME_TO = 'rename to';
+ public const RENAME_ATTRIBUTE = 'rename attribute';
public const RENAME_COLUMN = 'rename column';
public const RENAME_CONSTRAINT = 'rename constraint';
+ public const RENAME_TO = 'rename to';
public const REPLICA_IDENTITY = 'replica identity';
public const REPLICATION = 'replication';
public const RESET = 'reset';
public const SESSION_USER = 'session user';
public const SET = 'set';
public const SET_DATA = 'set data';
+ public const SET_DATA_TYPE = 'set data type';
public const SET_DEFAULT = 'set default';
public const SET_LOGGED = 'set logged';
public const SET_PUBLICATION = 'set publication';
public const USING_INDEX = 'using index';
public const VALIDATOR = 'validator';
public const VALIDATE_CONSTRAINT = 'validate constraint';
- public const VALIDUNTIL = 'validuntil';
+ public const VALID_UNTIL = 'valid until';
public const VARIADIC = 'variadic';
public const VERSION = 'version';
public const VOLATILE = 'volatile';
/**
* Codes associated with database actions.
*/
-class e_database_action {
+class e_database_action_deprecated {
public const NONE = 0;
public const ADD = 1;
public const DISABLE = 2;
--- /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 attribute actions.
+ */
+class e_database_attribute_action {
+ public const NONE = 0;
+ public const ADD = 1;
+ public const ALTER = 2;
+ public const DROP = 3;
+}
public const PASSWORD_ENCRYPTED = 15;
public const REPLICATION = 16;
public const SUPERUSER = 17;
- public const VALIDUNTIL = 18;
+ public const VALID_UNTIL = 18;
}
--- /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 server option and related queries.
+ */
+class e_database_server_option {
+ public const NONE = 0;
+ public const ADD = 1;
+ public const DROP = 2;
+ public const SET = 3;
+}
*/
class e_database_user {
public const NONE = 0;
- public const CURRENT = 1;
- public const SESSION = 2;
+ public const ALL = 1;
+ public const CURRENT = 2;
public const NAME = 3;
- public const ALL = 4;
+ public const PUBLIC = 4;
+ public const SESSION = 5;
}
* @file
* Provides traits for specific Postgesql Queries.
*
- * These traits are associated with actions
- *
- * @fixme: redesign/rewrite/replace this.
- *
* @see: https://www.postgresql.org/docs/current/static/sql-commands.html
*/
namespace n_koopa;
require_once('common/database/classes/database_string.php');
/**
- * Provide action support for an SQL query.
- *
- * An action is a class-specific action such as SELECT, INSERT, etc...
- * A query only performs one action.
+ * Provide the sql action names functionality.
*/
trait t_database_action {
protected $action;
/**
- * Assigns this query action.
+ * Set the settings.
*
- * @param int|null $action
- * Whether or not to use a class-specific action such as SELECT, INSERT, etc...
+ * @param string|null $name
+ * The type action name.
* Set to NULL to disable.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
- * FALSE with error bit set is returned on error.
+ * FALSE with the error bit set is returned on error.
*/
- public function set_action($action) {
- if (is_null($action)) {
+ public function set_action($name) {
+ if (is_null($option)) {
$this->action = NULL;
return new c_base_return_true();
}
- if (is_int($action)) {
- $this->action = $action;
- return new c_base_return_true();
- }
-
- $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);
- }
-
- /**
- * Get the currently assigned action.
- *
- * @return c_base_return_int|c_base_return_null
- * Integer representing the action is returned.
- * NULL is returned if undefined.
- * FALSE with error bit set is returned on error.
- */
- protected function get_action() {
- if (is_null($this->action)) {
- return new c_base_return_null();
+ 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);
}
- return c_base_return_int::s_new($this->action);
- }
-}
-
-/**
- * Provide action property support for an SQL query.
- *
- * A single property that is associated with a particular action.
- */
-trait t_database_action_property {
- protected $action_property;
-
- /**
- * Assigns this query action property.
- *
- * @param int|null $action_property
- * Whether or not to use a action property associated.
- * 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_action_property($action_property) {
- if (is_null($action_property)) {
- $this->action_property = NULL;
- return new c_base_return_true();
- }
-
- if (is_int($action_property)) {
- $this->action_property = $action_property;
- return new c_base_return_true();
+ if (!is_array($this->action)) {
+ $this->action = [];
}
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'action_property', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ $this->action[] = $name;
+ return new c_base_return_true();
}
/**
- * Get the currently assigned action property.
+ * Get the currently assigned settings.
*
- * @return c_base_return_int|c_base_return_null
- * Integer representing the action property is returned.
- * NULL is returned if undefined.
- * FALSE with error bit set is returned on error.
+ * @return c_base_return_array|c_base_return_null
+ * An array of type action names.
+ * NULL is returned if not set (publication name not to be used).
+ * NULL with the error bit set is returned on error.
*/
- protected function get_action_property() {
- if (is_null($this->action_property)) {
+ public function get_action() {
+ if (is_null($this->action)) {
return new c_base_return_null();
}
- return c_base_return_int::s_new($this->action_property);
- }
-}
-
-/**
- * Provide parameter(s) associated with an action or action property support for an SQL query.
- *
- * A single parameter, a database query object, or an array of parameters that are associated with a particular action or action property.
- */
-trait t_database_action_parameter {
- protected $action_parameter;
-
- /**
- * Assigns this query action parameter(s).
- *
- * @param c_base_return_string|c_base_return_array|c_database_query|null $action_parameter
- * Whether or not to use a specified action parameter or array of parameters.
- * 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_action_parameter($action_parameter) {
- if (is_null($action_parameter)) {
- $this->action_parameter = NULL;
- return new c_base_return_true();
- }
-
- if (is_string($action_parameter)) {
- $this->action_parameter = $action_parameter;
- return new c_base_return_true();
- }
-
- if (is_array($action_parameter)) {
- $this->action_parameter = $action_parameter;
- return new c_base_return_true();
+ if (is_array($this->action)) {
+ return c_base_return_array::s_new($this->action);
}
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'action_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
}
/**
- * Get the currently assigned action parameter.
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
*
- * @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.
- * NULL is returned if undefined.
- * FALSE with error bit set is returned on error.
+ * @return string|null
+ * A string is returned.
+ * NULL is returned if there is nothing to process or there is an error.
*/
- protected function get_action_parameter() {
- if (is_null($this->action_parameter)) {
- return new c_base_return_null();
- }
-
- if (is_array($this->action_parameter)) {
- return c_base_return_array::s_new($this->action_parameter);
- }
-
- if ($this->action_parameter instanceof c_database_query) {
- return clone($this->action_parameter);
- }
-
- return c_base_return_string::s_new($this->action_parameter);
+ protected function p_do_build_action() {
+ return implode(', ', $this->action);
}
}
/**
* 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) {
+ public function get_action_alter_column_options() {
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);
+ if (is_array($this->action_alter_column_options)) {
+ return c_base_return_array::s_new($this->action_alter_column_options);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_alter_column_options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* 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) {
+ public function get_action_alter_column_reset() {
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);
+ if (is_array($this->action_alter_column_reset)) {
+ return c_base_return_array::s_new($this->action_alter_column_reset);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_alter_column_reset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* 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) {
+ public function get_action_alter_column_set() {
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);
+ if (is_array($this->action_alter_column_set)) {
+ return c_base_return_array::s_new($this->action_alter_column_set);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_alter_column_set', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * These traits are associated with actions
+ *
+ * @fixme: redesign/rewrite/replace this.
+ *
+ * @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 action support for an SQL query.
+ *
+ * An action is a class-specific action such as SELECT, INSERT, etc...
+ * A query only performs one action.
+ */
+trait t_database_action_deprecated {
+ protected $action;
+
+ /**
+ * Assigns this query action.
+ *
+ * @param int|null $action
+ * Whether or not to use a class-specific action such as SELECT, INSERT, etc...
+ * 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_action($action) {
+ if (is_null($action)) {
+ $this->action = NULL;
+ return new c_base_return_true();
+ }
+
+ if (is_int($action)) {
+ $this->action = $action;
+ return new c_base_return_true();
+ }
+
+ $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);
+ }
+
+ /**
+ * Get the currently assigned action.
+ *
+ * @return c_base_return_int|c_base_return_null
+ * Integer representing the action is returned.
+ * NULL is returned if undefined.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function get_action() {
+ if (is_null($this->action)) {
+ return new c_base_return_null();
+ }
+
+ return c_base_return_int::s_new($this->action);
+ }
+}
+
+/**
+ * Provide action property support for an SQL query.
+ *
+ * A single property that is associated with a particular action.
+ */
+trait t_database_action_property_deprecated {
+ protected $action_property;
+
+ /**
+ * Assigns this query action property.
+ *
+ * @param int|null $action_property
+ * Whether or not to use a action property associated.
+ * 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_action_property($action_property) {
+ if (is_null($action_property)) {
+ $this->action_property = NULL;
+ return new c_base_return_true();
+ }
+
+ if (is_int($action_property)) {
+ $this->action_property = $action_property;
+ return new c_base_return_true();
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'action_property', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ /**
+ * Get the currently assigned action property.
+ *
+ * @return c_base_return_int|c_base_return_null
+ * Integer representing the action property is returned.
+ * NULL is returned if undefined.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function get_action_property() {
+ if (is_null($this->action_property)) {
+ return new c_base_return_null();
+ }
+
+ return c_base_return_int::s_new($this->action_property);
+ }
+}
+
+/**
+ * Provide parameter(s) associated with an action or action property support for an SQL query.
+ *
+ * A single parameter, a database query object, or an array of parameters that are associated with a particular action or action property.
+ */
+trait t_database_action_parameter {
+ protected $action_parameter;
+
+ /**
+ * Assigns this query action parameter(s).
+ *
+ * @param c_base_return_string|c_base_return_array|c_database_query|null $action_parameter
+ * Whether or not to use a specified action parameter or array of parameters.
+ * 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_action_parameter($action_parameter) {
+ if (is_null($action_parameter)) {
+ $this->action_parameter = NULL;
+ return new c_base_return_true();
+ }
+
+ if (is_string($action_parameter)) {
+ $this->action_parameter = $action_parameter;
+ return new c_base_return_true();
+ }
+
+ if (is_array($action_parameter)) {
+ $this->action_parameter = $action_parameter;
+ return new c_base_return_true();
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'action_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($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.
+ * NULL is returned if undefined.
+ * FALSE with error bit set is returned on error.
+ */
+ protected function get_action_parameter() {
+ if (is_null($this->action_parameter)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->action_parameter)) {
+ return c_base_return_array::s_new($this->action_parameter);
+ }
+
+ if ($this->action_parameter instanceof c_database_query) {
+ return clone($this->action_parameter);
+ }
+
+ return c_base_return_string::s_new($this->action_parameter);
+ }
+}
/**
* 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) {
+ public function get_action_options() {
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);
+ if (is_array($this->action_options)) {
+ return c_base_return_array::s_new($this->action_options);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* Get the add/drop user settings.
*
- * @param int|null $index
- * (optional) Get the argument type array at the specified index.
- * When NULL, all argument type are returned.
- *
* @return c_base_return_array|c_base_return_null
- * An array representing the add/drop operator settings at the $index.
- * An array representing all add/drop operator settings when $index is NULL.
+ * An array representing the add/drop operator settings.
* NULL is returned if not set (add/drop operator is not to be used).
* NULL with the error bit set is returned on error.
*/
- public function get_add_operator_family($index = NULL) {
+ public function get_add_operator_family() {
if (is_null($this->add_operator_family)) {
return new c_base_return_null();
}
- if (is_null($index)) {
+ if (is_array($this->add_operator_family)) {
return c_base_return_array::s_new($this->add_operator_family);
}
- else if (isset($this->add_operator_family['values'][$index]) && is_array($this->add_operator_family['values'][$index])) {
- return c_base_return_array::s_new($this->add_operator_family['values'][$index]);
- }
- else {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'argument_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_null($error);
- }
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'add_operator_family', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_null($error);
*/
protected function p_do_build_add_value() {
$value = c_database_string::ADD_VALUE;
+ // @todo: confirm/deny whether or not the placeholder will be auto-quoted by PDO.
$value .= ' \'' . $this->add_value['new_enum_value'] . '\'';
if ($this->add_value['if_not_exists']) {
$value .= ' ' . c_database_string::BEFORE;
}
+ // @todo: confirm/deny whether or not the placeholder will be auto-quoted by PDO.
$value .= ' \'' . $this->add_value['neighbor_enum_value'] . '\'';
}
}
/**
- * Get the currently assigned sql argument type at the specified index.
- *
- * @param int|null $index
- * (optional) Get the argument type array at the specified index.
- * When NULL, all argument type are returned.
+ * Get the currently assigned sql argument type.
*
* @return c_base_return_array|c_base_return_null
- * An array representing the argument type at the $index.
- * An array representing all argument types when $index is NULL.
- * NULL is returned if not set (argument type tablespace is not to be used).
+ * An array representing all argument types.
+ * NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
- public function get_argument_type($index = NULL) {
+ public function get_argument_type() {
if (is_null($this->argument_type)) {
return new c_base_return_null();
}
- if (is_null($index)) {
+ if (is_array($this->argument_type)) {
return c_base_return_array::s_new($this->argument_type);
}
- else if (isset($this->argument_type[$index]) && is_array($this->argument_type[$index])) {
- return c_base_return_array::s_new($this->argument_type[$index]);
- }
- else {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'argument_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_null($error);
- }
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'argument_type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
return c_base_return_error::s_null($error);
}
/**
- * Get the currently assigned COLUMN_RESET attribute option at the specified index.
+ * Get the currently assigned COLUMN_RESET attribute option.
*
- * @param int|null $index
- * (optional) Get the index attribute option type at the specified index.
- * When NULL, all index attribute option types are returned.
- *
- * @return c_base_return_array|c_base_return_int|c_base_return_null
- * A code or an array of codes representing the argument_type on success.
- * NULL is returned if not set (column_reset tablespace is not to be used).
+ * @return c_base_return_array|c_base_return_null
+ * An array of codes representing the argument_type on success.
+ * NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
- public function get_column_reset($index = NULL) {
+ public function get_column_reset() {
if (is_null($this->column_reset)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->column_reset)) {
- return c_base_return_array::s_new($this->column_reset);
- }
- }
- else {
- if (is_int($index) && isset($this->column_reset['values'][$index]) && is_int($this->column_reset['values'][$index])) {
- return c_base_return_int::s_new($this->column_reset['values'][$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'column_reset[values][index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->column_reset)) {
+ return c_base_return_array::s_new($this->column_reset);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'column_reset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
}
/**
- * Get the currently assigned COLUMN .. SET index attribute option at the specified index.
- *
- * @param int|null $index
- * (optional) Get the index attribute option type at the specified index.
- * When NULL, all index attribute option types are returned.
+ * Get the currently assigned COLUMN .. SET index attribute option.
*
* @return c_base_return_array|c_base_return_null
* 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.
*/
- public function get_column_set($index = NULL) {
+ public function get_column_set() {
if (is_null($this->column_set)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->column_set)) {
- return c_base_return_array::s_new($this->column_set);
- }
- }
- else {
- if (is_int($index) && isset($index, $this->column_set['values']) && is_array($this->column_set['values'][$index])) {
- return c_base_return_array::s_new($this->column_set['values'][$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'column_set[values][index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->column_set)) {
+ return c_base_return_array::s_new($this->column_set);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'column_set', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* Get the currently assigned add table settings.
*
- * @param int|null $index
- * (optional) Get the add table settings at the specified index.
- * When NULL, all add table settings are returned.
- *
* @return c_base_return_array|c_base_return_null
* An array containing the add table settings.
* NULL is returned if not set (add table not to be used).
return new c_base_return_null();
}
- if (isset($this->drop_value)) {
+ if (is_array($this->drop_value)) {
return c_base_return_array::s_new($this->drop_value);
}
/**
* Get the currently assigned for role value.
*
- * @param int|null $index
- * (optional) Get the for role at the specified index.
- * When NULL, all for role values are returned.
- *
- * @return i_database_query_placeholder|c_base_return_array|c_base_return_null
+ * @return c_base_return_array|c_base_return_null
* An array of for roles or NULL if not defined.
- * A single for role query placeholder is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_for_role($index = NULL) {
+ public function get_for_role() {
if (is_null($this->for_role)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->for_role)) {
- return c_base_return_array::s_new($this->for_role);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->for_role) && isset($this->for_role[$index])) {
- return clone($this->for_role[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'for_role[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->for_role)) {
+ return c_base_return_array::s_new($this->for_role);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'for_role', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
* NULL is returned if not set (function action tablespace is not to be used).
* NULL with the error bit set is returned on error.
*/
- public function get_function_action($index = NULL) {
+ public function get_function_action() {
if (is_null($this->function_action)) {
return new c_base_return_null();
}
/**
* Get the currently assigned for group by value.
*
- * @param int|null $index
- * (optional) Get the group by at the specified index.
- * When NULL, all group by values are returned.
- *
- * @return i_database_query_placeholder|c_base_return_array|c_base_return_null
+ * @return c_base_return_array|c_base_return_null
* An array of group by values or NULL if not defined.
- * A single group by query placeholder is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_group_by($index = NULL) {
+ public function get_group_by() {
if (is_null($this->group_by)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->group_by)) {
- return c_base_return_array::s_new($this->group_by);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->group_by) && isset($this->group_by[$index])) {
- return clone($this->group_by[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'group_by[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->group_by)) {
+ return c_base_return_array::s_new($this->group_by);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'group_by', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* Get the in schema, schema names.
*
- * @param int|null $index
- * (optional) Get the schema name at the specified index.
- * When NULL, all schema names are returned.
- *
- * @return i_database_query_placeholder|c_base_return_array|c_base_return_null
+ * @return c_base_return_array|c_base_return_null
* An array of schema names or NULL if not defined.
- * A single schema name query placeholder is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_in_schema($index = NULL) {
+ public function get_in_schema() {
if (is_null($this->in_schema)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->in_schema)) {
- return c_base_return_array::s_new($this->in_schema);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->in_schema) && isset($this->in_schema[$index])) {
- return clone($this->in_schema[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'in_schema[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->in_schema)) {
+ return c_base_return_array::s_new($this->in_schema);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'in_schema', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* Get the options.
*
- * @param int|null $index
- * (optional) Get the options at the specified index.
- * When NULL, all options are returned.
- *
* @return c_base_return_array|c_base_return_null
* An array of options arrays or NULL if not defined.
- * A single options array is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_options($index = NULL) {
+ public function get_options() {
if (is_null($this->options)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->options)) {
- return c_base_return_array::s_new($this->options);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->options) && is_array($this->options[$index])) {
- return c_base_return_array::s_new($this->options[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'options[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->options)) {
+ return c_base_return_array::s_new($this->options);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* Get the currently assigned for group by value.
*
- * @param int|null $index
- * (optional) Get the group by at the specified index.
- * When NULL, all group by values are returned.
- *
- * @return i_database_query_placeholder|c_base_return_array|c_base_return_null
+ * @return c_base_return_array|c_base_return_null
* An array of group by values or NULL if not defined.
- * A single group by query placeholder is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_order_by($index = NULL) {
+ public function get_order_by() {
if (is_null($this->order_by)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->order_by)) {
- return c_base_return_array::s_new($this->order_by);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->order_by) && isset($this->order_by[$index])) {
- return clone($this->order_by[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'order_by[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->order_by)) {
+ return c_base_return_array::s_new($this->order_by);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'order_by', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
}
/**
- * Get the owned_by.
+ * Get the owned by settings.
*
- * @param int|null $index
- * (optional) Get the owned_by at the specified index.
- * When NULL, all owned_by are returned.
- *
- * @return c_base_return_int|i_database_query_placeholder|c_base_return_array|c_base_return_null
+ * @return c_base_return_array|c_base_return_null
* An array of owned_by or NULL if not defined.
- * A single owned_by is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_owned_by($index = NULL) {
+ public function get_owned_by() {
if (is_null($this->owned_by)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if ($this->owned_by === e_database_user::ALL || $this->owned_by === e_database_user::NONE) {
- return c_base_return_array::s_new([$this->owned_by]);
- }
- else if (is_array($this->owned_by)) {
- return c_base_return_array::s_new($this->owned_by);
- }
+ if ($this->owned_by === e_database_user::ALL || $this->owned_by === e_database_user::NONE) {
+ return c_base_return_array::s_new([$this->owned_by]);
}
- else if (is_int($index)) {
- if (array_key_exists($index, $this->owned_by)) {
- if (is_int($this->owned_by[$index])) {
- return c_base_return_int::s_new($this->owned_by[$index]);
- }
- else if (isset($this->owned_by[$index])) {
- return clone($this->owned_by[$index]);
- }
- }
- else {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'owned_by[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
- }
+ else if (is_array($this->owned_by)) {
+ return c_base_return_array::s_new($this->owned_by);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'owned_by', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* Get the privileges.
*
- * @param int|null $index
- * (optional) Get the privilege at the specified index.
- * When NULL, all privileges are returned.
- *
- * @return c_base_return_int|c_base_return_array|c_base_return_null
+ * @return c_base_return_array|c_base_return_null
* An array of privileges or NULL if not defined.
- * A single privilege is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_privilege($index = NULL) {
+ public function get_privilege() {
if (is_null($this->privilege)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if ($this->privilege === e_database_privilege::ALL) {
- return c_base_return_array::s_new([$this->privilege]);
- }
- else if (is_array($this->privilege)) {
- return c_base_return_array::s_new($this->privilege);
- }
+ if ($this->privilege === e_database_privilege::ALL) {
+ return c_base_return_array::s_new([$this->privilege]);
}
- else {
- if (is_int($index) && array_key_exists($index, $this->privilege) && is_int($this->privilege[$index])) {
- return clone($this->privilege[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'privilege[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ else if (is_array($this->privilege)) {
+ return c_base_return_array::s_new($this->privilege);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'privilege', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
* NULL is returned if not set (refresh publication not to be used).
* NULL with the error bit set is returned on error.
*/
- public function get_refresh_publication($index = NULL) {
+ public function get_refresh_publication() {
if (is_null($this->refresh_publication)) {
return new c_base_return_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');
+
+require_once('common/database/enumerations/database_cascade.php');
+
+/**
+ * Provide the sql RENAME ATTRIBUTE functionality.
+ */
+trait t_database_rename_attribute {
+ protected $rename_attribute;
+
+ /**
+ * Set the RENAME ATTRIBUTE settings.
+ *
+ * @param string|null $from
+ * The name to rename from.
+ * Set to NULL to disable.
+ * @param string|null $to
+ * (optional) The name to rename to.
+ * Required when $from 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_rename_attribute($from, $to = NULL, $cascade = NULL) {
+ if (is_null($from)) {
+ $this->rename_attribute = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($from)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'from', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_string($to)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'to', ':{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:
+ case NULL:
+ 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_from = $this->add_placeholder($from);
+ if ($placeholder_from->has_error()) {
+ return c_base_return_error::s_false($placeholder_from->get_error());
+ }
+
+ $placeholder_to = $this->add_placeholder($to);
+ if ($placeholder_to->has_error()) {
+ unset($placeholder_from);
+ return c_base_return_error::s_false($placeholder_to->get_error());
+ }
+
+ $this->rename_attribute = [
+ 'from' => $placeholder_from,
+ 'to' => $placeholder_to,
+ 'cascade' => $cascade,
+ ];
+ unset($placeholder_from);
+ unset($placeholder_to);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned nsettings.
+ *
+ * @return c_database_return_array|c_base_return_null
+ * An array containing the settings.
+ * NULL is returned if not set (rename to is not to be used).
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_rename_attribute() {
+ if (is_null($this->rename_attribute)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->rename_attribute)) {
+ return c_database_return_array::s_new($this->rename_attribute);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'rename_attribute', ':{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_attribute() {
+ $value = c_database_string::RENAME_ATTRIBUTE;
+ $value .= ' ' . $this->rename_attribute['from'];
+ $value .= ' ' . c_database_string::TO;
+ $value .= ' ' . $this->rename_attribute['to'];
+
+ if ($this->rename_attribute['cascade'] === e_database_cascade::CASCADE) {
+ $value .= ' ' . c_database_string::CASCADE;
+ }
+ else if ($this->rename_attribute['cascade'] === e_database_cascade::RESTRICT) {
+ $value .= ' ' . c_database_string::RESTRICT;
+ }
+
+ 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/classes/database_string.php');
+
+/**
+ * Provide the sql RENAME VALUE functionality.
+ */
+trait t_database_rename_value {
+ protected $rename_value;
+
+ /**
+ * Set the RENAME VALUE settings.
+ *
+ * @param string|null $from
+ * The name to rename from.
+ * Set to NULL to disable.
+ * @param string|null $to
+ * (optional) The name to rename to.
+ * Required when $from 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_rename_value($from, $to = NULL) {
+ if (is_null($from)) {
+ $this->rename_value = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($from)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'from', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_string($to)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'to', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $placeholder_from = $this->add_placeholder($from);
+ if ($placeholder_from->has_error()) {
+ return c_base_return_error::s_false($placeholder_from->get_error());
+ }
+
+ $placeholder_to = $this->add_placeholder($to);
+ if ($placeholder_to->has_error()) {
+ unset($placeholder_from);
+ return c_base_return_error::s_false($placeholder_to->get_error());
+ }
+
+ $this->rename_value = [
+ 'from' => $placeholder_from,
+ 'to' => $placeholder_to,
+ ];
+ unset($placeholder_from);
+ unset($placeholder_to);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned nsettings.
+ *
+ * @return c_database_return_array|c_base_return_null
+ * An array containing the settings.
+ * NULL is returned if not set (rename to is not to be used).
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_rename_value() {
+ if (is_null($this->rename_value)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->rename_value)) {
+ return c_database_return_array::s_new($this->rename_value);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'rename_value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_rename_value() {
+ $value = c_database_string::RENAME_ATTRIBUTE;
+ $value .= ' ' . $this->rename_value['from'];
+ $value .= ' ' . c_database_string::TO;
+ $value .= ' ' . $this->rename_value['to'];
+ return $value;
+ }
+}
}
/**
- * Get the currently assigned RESET storage parameter at the specified index.
- *
- * @param int|null $index
- * (optional) Get the index storage parameter type at the specified index.
- * When NULL, all index storage parameter types are returned.
+ * Get the currently assigned RESET storage parameter.
*
* @return c_base_return_array|c_base_return_int|c_base_return_null
* A code or an array of codes representing the argument_type on success.
* NULL is returned if not set (reset_storage_parameter tablespace is not to be used).
* NULL with the error bit set is returned on error.
*/
- public function get_reset_storage_parameter($index = NULL) {
+ public function get_reset_storage_parameter() {
if (is_null($this->reset_storage_parameter)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->reset_storage_parameter)) {
- return c_base_return_array::s_new($this->reset_storage_parameter);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->reset_storage_parameter) && is_int($this->reset_storage_parameter[$index])) {
- return c_base_return_int::s_new($this->reset_storage_parameter[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'reset_storage_parameter[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->reset_storage_parameter)) {
+ return c_base_return_array::s_new($this->reset_storage_parameter);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'reset_storage_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
* NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
- public function get_role_specification($index = NULL) {
+ public function get_role_specification() {
if (is_null($this->role_specification)) {
return new c_base_return_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');
+
+/**
+ * Provide the sql SERVER name functionality.
+ */
+trait t_database_server_name {
+ protected $server_name;
+
+ /**
+ * Set the SERVER settings.
+ *
+ * @param string|null $name
+ * The server name to use.
+ * Set to NULL to disable.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_server_name($name) {
+ if (is_null($name)) {
+ $this->server_name = NULL;
+ return new c_base_return_true();
+ }
+
+ if (is_string($name)) {
+ $placeholder = $this->add_placeholder($name);
+ if ($placeholder->has_error()) {
+ return c_base_return_error::s_false($placeholder->get_error());
+ }
+
+ $this->server_name = $placeholder;
+ unset($placeholder);
+
+ return new c_base_return_true();
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ /**
+ * Get the currently assigned server name.
+ *
+ * @return i_database_query_placeholder|c_base_return_null
+ * A server name query placeholder on success.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_server_name() {
+ if (is_null($this->server_name)) {
+ return new c_base_return_null();
+ }
+
+ if (isset($this->server_name)) {
+ return clone($this->server_name);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'server_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_server_name() {
+ return c_database_string::SERVER . ' ' . $this->server_name;
+ }
+}
--- /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_server_option.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql server OPTIONS functionality.
+ */
+trait t_database_server_options {
+ protected $server_options;
+
+ /**
+ * Set the OPTIONS (...) settings.
+ *
+ * @param int|null $option
+ * The server option code to assign.
+ * Should be one of: e_database_server_option.
+ * Set to NULL to disable.
+ * @param string|null $name
+ * (optional) The option name.
+ * This is ignored when $option is NULL.
+ * When NULL, this is ignored.
+ * @param string|null $value
+ * (optional) The value associated with the option name.
+ * This is ignored when $option is NULL.
+ * When NULL, this is ignored.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_server_options($option, $name = NULL, $value = NULL) {
+ if (is_null($option)) {
+ $this->server_options = NULL;
+ return new c_base_return_true();
+ }
+
+ switch ($option) {
+ case server_option::ADD:
+ case server_option::DROP:
+ case server_option::SET:
+ break;
+ default:
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_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);
+ }
+
+ $placeholder_name = $this->add_placeholder($value);
+ if ($placeholder_name->has_error()) {
+ return c_base_return_error::s_false($placeholder_name->get_error());
+ }
+
+ $placeholder_value = NULL;
+ if (!is_null($value)) {
+ 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_value = $this->add_placeholder($value);
+ if ($placeholder_value->has_error()) {
+ return c_base_return_error::s_false($placeholder_value->get_error());
+ }
+ }
+
+ if (!is_array($this->server_options)) {
+ $this->server_options = [];
+ }
+
+ $this->server_options[] = [
+ 'option' => $option,
+ 'name' => $placeholder_name,
+ 'value' => $placeholder_value,
+ ];
+ unset($placeholder_name);
+ unset($placeholder_value);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned WITH refresh option.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing the with server 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.
+ */
+ public function get_server_options() {
+ if (is_null($this->server_options)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->server_options)) {
+ return c_base_return_array::s_new($this->server_options);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'server_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_server_options() {
+ $values = [];
+ foreach ($this->server_options as $option) {
+ if ($parameter === server_option::ADD) {
+ $value = c_database_string::ADD . ' =';
+ $value .= ' ' . $option['name'];
+
+ if (isset($option['value'])) {
+ $value .= ' ' . $option['value'];
+ }
+
+ $values[] = $value;
+ }
+ else if ($parameter === server_option::DROP) {
+ $value = c_database_string::DROP;
+ $value .= ' ' . $option['name'];
+ $values[] = $value;
+ }
+ else if ($parameter === server_option::SET) {
+ $value = c_database_string::SET . ' =';
+ $value .= ' ' . $option['name'];
+
+ if (isset($option['value'])) {
+ $value .= ' ' . $option['value'];
+ }
+
+ $values[] = $value;
+ }
+ }
+ unset($option);
+ unset($value);
+
+ return c_database_string::OPTIONS . ' (' . implode(', ', $values) . ')';
+ }
+}
/**
* Get the (operator) SET values.
*
- * @param int|null $index
- * (optional) Get the set parameter and value at the specified index.
- * When NULL, all parameters and values are returned.
- *
* @return c_base_return_array|c_base_return_null
* An array of parameters and values or NULL if not defined.
- * A single parameters and value array is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_set_operator($index = NULL) {
+ public function get_set_operator() {
if (is_null($this->set_operator)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->set_operator)) {
- return c_base_return_array::s_new($this->set_operator);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->set_operator)) {
- return c_base_return_array::s_new($this->set_operator[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_operator[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->set_operator)) {
+ return c_base_return_array::s_new($this->set_operator);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_operator', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
}
/**
- * Get the currently assigned SET PUBLICATION name at the specified index.
+ * Get the currently assigned SET PUBLICATION name.
*
- * @param int|null $index
- * (optional) Get the publication name at the specified index.
- * When NULL, all publication names are returned.
- *
- * @return c_base_return_array|c_base_return_string|c_base_return_null
- * An array of publication names or a string representing the publication name at $index..
- * NULL is returned if not set (publication name not to be used).
+ * @return c_base_return_array|c_base_return_null
+ * An array of publication names.
+ * NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
- public function get_set_publication_name($index = NULL) {
+ public function get_set_publication_name() {
if (is_null($this->set_publication_name)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->set_publication_name)) {
- return c_base_return_array::s_new($this->set_publication_name);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->set_publication_name)) {
- return c_base_return_string::s_new($this->set_publication_name[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_publication_name[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->set_publication_name)) {
+ return c_base_return_array::s_new($this->set_publication_name);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_publication_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
}
/**
- * Get the currently assigned SET publication parameter at the specified index.
- *
- * @param int|null $index
- * (optional) Get the publication parameter type at the specified index.
- * When NULL, all publication parameter types are returned.
+ * Get the currently assigned SET publication parameter.
*
* @return c_base_return_array|c_base_return_null
* 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.
*/
- public function get_set_publication_parameter($index = NULL) {
+ public function get_set_publication_parameter() {
if (is_null($this->set_publication_parameter)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->set_publication_parameter)) {
- return c_base_return_array::s_new($this->set_publication_parameter);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->set_publication_parameter)) {
- return c_base_return_array::s_new($this->set_publication_parameter[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_publication_parameter[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->set_publication_parameter)) {
+ return c_base_return_array::s_new($this->set_publication_parameter);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_publication_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
}
/**
- * Get the currently assigned SET index storage parameter at the specified index.
- *
- * @param int|null $index
- * (optional) Get the index storage parameter type at the specified index.
- * When NULL, all index storage parameter types are returned.
+ * Get the currently assigned SET index storage parameter.
*
* @return c_base_return_array|c_base_return_null
* An array containing the set index storage parameter settings.
- * NULL is returned if not set (set index storage parameter not to be used).
+ * NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
- public function get_set_storage_parameter($index = NULL) {
+ public function get_set_storage_parameter() {
if (is_null($this->set_storage_parameter)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->set_storage_parameter)) {
- return c_base_return_array::s_new($this->set_storage_parameter);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->set_storage_parameter)) {
- return c_base_return_array::s_new($this->set_storage_parameter[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_storage_parameter[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->set_storage_parameter)) {
+ return c_base_return_array::s_new($this->set_storage_parameter);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_storage_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
/**
* Get the currently assigned add table settings.
*
- * @param int|null $index
- * (optional) Get the add table settings at the specified index.
- * When NULL, all add table settings are returned.
- *
* @return c_base_return_array|c_base_return_null
* An array containing the add table settings.
- * NULL is returned if not set (add table not to be used).
+ * NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
public function get_set_table() {
return new c_base_return_null();
}
- if (isset($this->set_table)) {
+ if (is_array($this->set_table)) {
return c_base_return_array::s_new($this->set_table);
}
/**
* Get the in schema, to roles.
*
- * @param int|null $index
- * (optional) Get the schema name at the specified index.
- * When NULL, all to roles are returned.
- *
* @return c_base_return_array|c_base_return_null
* An array of to role arrays or NULL if not defined.
- * A single to role array is returned if $index is an integer.
* NULL with the error bit set is returned on error.
*/
- public function get_to_role($index = NULL) {
+ public function get_to_role() {
if (is_null($this->to_role)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->to_role)) {
- return c_base_return_array::s_new($this->to_role);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->to_role)) {
- return c_base_return_array::s_new($this->to_role[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'to_role[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->to_role)) {
+ return c_base_return_array::s_new($this->to_role);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'to_role', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
--- /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');
+
+require_once('common/database/enumerations/database_attribute_action.php');
+require_once('common/database/enumerations/database_attribute_cascade.php');
+
+/**
+ * Provide the sql type actions functionality.
+ */
+trait t_database_type_action {
+ protected $type_action;
+
+ /**
+ * Set the settings.
+ *
+ * @param int|null $attribute
+ * The attribute type to use from e_database_attribute_action.
+ * Set to NULL to disable.
+ * @param string|null $name
+ * (optional) The attribute name.
+ * Required when $attribute is not NULL.
+ * @param int|null $cascade
+ * (optional) The e_database_cascade property to use.
+ * @param string|null $type
+ * (optional) The attribute data type.
+ * Ignored when not applicable.
+ * @param string|null $collation
+ * (optional) The collation name.
+ * Ignored when not applicable.
+ * @param bool|null $if_exists
+ * (optional) TRUE for IF EXISTS, FALSE to not specify.
+ * Ignored when not applicable.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_type_action($attribute, $name = NULL, $cascade = NULL, $type = NULL, $collation = NULL, $if_exists = NULL) {
+ if (is_null($attribute)) {
+ $this->type_action = NULL;
+ return new c_base_return_true();
+ }
+
+ $placeholder = $this->add_placeholder($name);
+ if ($placeholder->has_error()) {
+ return c_base_return_error::s_false($placeholder->get_error());
+ }
+
+ $type_action = [
+ 'attribute' => $attribute,
+ 'name' => $placeholder,
+ 'cascade' => NULL,
+ 'type' => NULL,
+ 'collation' => NULL,
+ 'if_exists' => NULL,
+ ];
+ unset($placeholder);
+
+ if ($attribute === e_database_attribute_action::ADD) {
+ if (is_null($collation)) {
+ $placeholder = NULL;
+ }
+ else if (is_string($collation)) {
+ $placeholder = $this->add_placeholder($collation);
+ if ($placeholder->has_error()) {
+ unset($type_action);
+ return c_base_return_error::s_false($placeholder->get_error());
+ }
+ }
+ else {
+ unset($type_action);
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'collation', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $type_action['collation'] = $placeholder;
+ }
+ else if ($attribute === e_database_attribute_action::ALTER) {
+ if (is_null($collation)) {
+ $placeholder = NULL;
+ }
+ else if (is_string($collation)) {
+ $placeholder = $this->add_placeholder($collation);
+ if ($placeholder->has_error()) {
+ unset($type_action);
+ return c_base_return_error::s_false($placeholder->get_error());
+ }
+ }
+ else {
+ unset($type_action);
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'collation', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $type_action['collation'] = $placeholder;
+ }
+ else if ($attribute === e_database_attribute_action::DROP) {
+ if (!is_null($if_exists) && !is_bool($if_exists)) {
+ unset($type_action);
+ $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);
+ }
+
+ $type_action['if_exists'] = $if_exists;
+ }
+ else {
+ unset($type_action);
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ 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);
+ }
+
+ switch($cascade) {
+ case e_database_cascade::CASCADE:
+ case e_database_cascade::RESTRICT:
+ break;
+ default:
+ unset($type_action);
+ $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);
+ }
+
+ $this->type_action = $type_action;
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned settings.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array of type settings.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_type_action() {
+ if (is_null($this->type_action)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->type_action)) {
+ return c_base_return_array::s_new($this->type_action);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'type_action', ':{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_type_action() {
+ $value = NULL;
+
+ if ($this->type_action['attribute'] === e_database_attribute_action::ADD) {
+ $value = c_database_string::ADD_ATTRIBUTE;
+ $value .= ' ' . $this->type_action['name'];
+ $value .= ' ' . $this->type_action['data_type'];
+
+ if (isset($this->type_action['collation'])) {
+ $value .= ' ' . c_database_string::COLLATE;
+ $value .= ' ' . $this->type_action['collation'];
+ }
+ }
+ else if ($this->type_action['attribute'] === e_database_attribute_action::ALTER) {
+ $value = c_database_string::ALTER_ATTRIBUTE;
+ $value .= ' ' . $this->type_action['name'];
+ $value .= ' ' . c_database_string::SET_DATA_TYPE;
+ $value .= ' ' . $this->type_action['data_type'];
+
+ if (isset($this->type_action['collation'])) {
+ $value .= ' ' . c_database_string::COLLATE;
+ $value .= ' ' . $this->type_action['collation'];
+ }
+ }
+ else if ($this->type_action['attribute'] === e_database_attribute_action::DROP) {
+ $value = c_database_string::DROP_ATTRIBUTE;
+ if ($this->type_action['if_exists']) {
+ $value .= ' ' . c_database_string::IF_EXISTS;
+ }
+
+ $value .= ' ' . $this->type_action['name'];
+ }
+
+ if ($this->type_action['cascade'] === c_database_string::CASCADE) {
+ $value .= ' ' . c_database_string::CASCADE;
+ }
+ else if ($this->type_action['cascade'] === c_database_string::RESTRICT) {
+ $value .= ' ' . c_database_string::RESTRICT;
+ }
+
+ 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/classes/database_string.php');
+
+require_once('common/database/enumerations/database_user.php');
+
+/**
+ * Provide the sql user name functionality.
+ */
+trait t_database_user_name {
+ protected $user_name;
+
+ /**
+ * Set the user name.
+ *
+ * @param int|null $type
+ * The user name type to use, from e_database_user.
+ * Set to NULL to disable.
+ * When NULL, this will remove all values.
+ * @param string|null $name
+ * (optional) The user name to use if needed by a given $type.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_user_name($type, $name = NULL) {
+ if (is_null($type)) {
+ $this->user_name = NULL;
+ return new c_base_return_true();
+ }
+
+ switch ($type) {
+ case e_database_user::CURRENT:
+ case e_database_user::PUBLIC:
+ case e_database_user::SESSION:
+ $placeholder = NULL;
+ break;
+ case e_database_user::NAME:
+ 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);
+ }
+
+ $placeholder = $this->add_placeholder($name);
+ if ($placeholder->has_error()) {
+ return c_base_return_error::s_false($placeholder->get_error());
+ }
+ 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);
+ }
+
+ $this->user_name = [
+ 'type' => $type,
+ 'name' => $placeholder,
+ ];
+ unset($placeholder);
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned settings.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array of type settings.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_user_name() {
+ if (is_null($this->user_name)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->user_name)) {
+ return c_base_return_array::s_new($this->user_name);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'user_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_user_name() {
+ $value = NULL;
+
+ if ($this->user_name['type'] === e_database_user::CURRENT) {
+ $value = c_database_string::CURRENT_USER;
+ }
+ else if ($this->user_name['type'] === e_database_user::PUBLIC) {
+ $value = c_database_string::PUBLIC;
+ }
+ else if ($this->user_name['type'] === e_database_user::SESSION) {
+ $value = c_database_string::SESSION_USER;
+ }
+ else if ($this->user_name['type'] === e_database_user::NAME) {
+ $value = $this->user_name['name'];
+ }
+
+ return $value;
+ }
+}
}
/**
- * Get the currently assigned WITH publication option at the specified index.
- *
- * @param int|null $index
- * (optional) Get the publication options at the specified index.
- * When NULL, all publication options are returned.
+ * Get the currently assigned WITH publication option.
*
* @return c_base_return_array|c_base_return_null
* An array containing the with publication option settings.
- * NULL is returned if not set (with publication option not to be used).
+ * NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
- public function get_with_publication_option($index = NULL) {
+ public function get_with_publication_option() {
if (is_null($this->with_publication_option)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->with_publication_option)) {
- return c_base_return_array::s_new($this->with_publication_option);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->with_publication_option)) {
- return c_base_return_array::s_new($this->with_publication_option[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_publication_option[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->with_publication_option)) {
+ return c_base_return_array::s_new($this->with_publication_option);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_publication_option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
}
/**
- * Get the currently assigned WITH refresh option at the specified index.
- *
- * @param int|null $index
- * (optional) Get the refresh options at the specified index.
- * When NULL, all refresh options are returned.
+ * Get the currently assigned WITH refresh option.
*
* @return c_base_return_array|c_base_return_null
* An array containing the with refresh option settings.
- * NULL is returned if not set (with refresh option not to be used).
+ * NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
- public function get_with_refresh_option($index = NULL) {
+ public function get_with_refresh_option() {
if (is_null($this->with_refresh_option)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->with_refresh_option)) {
- return c_base_return_array::s_new($this->with_refresh_option);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->with_refresh_option)) {
- return c_base_return_array::s_new($this->with_refresh_option[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_refresh_option[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->with_refresh_option)) {
+ return c_base_return_array::s_new($this->with_refresh_option);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_refresh_option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
case e_database_role_option::PASSWORD:
case e_database_role_option::PASSWORD_ENCRYPTED:
- case e_database_role_option::VALIDUNTIL:
+ case e_database_role_option::VALID_UNTIL:
if (is_string($value)) {
$placeholder = $this->add_placeholder($value);
if ($placeholder->has_error()) {
else if ($role_option['type'] === e_database_role_option::PASSWORD_ENCRYPTED) {
$values[] = c_database_string::PASSWORD_ENCRYPTED . ' ' . $role_option['value'];
}
- else if ($role_option['type'] === e_database_role_option::VALIDUNTIL) {
- $values[] = c_database_string::VALIDUNTIL . ' ' . $role_option['value'];
+ else if ($role_option['type'] === e_database_role_option::VALID_UNTIL) {
+ $values[] = c_database_string::VALID_UNTIL . ' ' . $role_option['value'];
}
}
unset($role_option);
}
/**
- * Get the currently assigned WITH index storage parameter at the specified index.
- *
- * @param int|null $index
- * (optional) Get the index storage parameter type at the specified index.
- * When NULL, all index storage parameter types are returned.
+ * Get the currently assigned WITH index storage parameter.
*
* @return c_base_return_array|c_base_return_null
* 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.
*/
- public function get_with_storage_parameter($index = NULL) {
+ public function get_with_storage_parameter() {
if (is_null($this->with_storage_parameter)) {
return new c_base_return_null();
}
- if (is_null($index)) {
- if (is_array($this->with_storage_parameter)) {
- return c_base_return_array::s_new($this->with_storage_parameter);
- }
- }
- else {
- if (is_int($index) && array_key_exists($index, $this->with_storage_parameter)) {
- return c_base_return_array::s_new($this->with_storage_parameter[$index]);
- }
-
- $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_storage_parameter[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
- return c_base_return_error::s_null($error);
+ if (is_array($this->with_storage_parameter)) {
+ return c_base_return_array::s_new($this->with_storage_parameter);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'with_storage_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);