$value .= ' ' . $this->p_do_build_rename_column();
}
- else if (is_array($this->rename_to)) {
+ else if (is_string($this->rename_to)) {
$value .= is_null($value) ? '' : ' ';
$value .= $this->p_do_build_rename_to();
}
use t_database_no_wait;
use t_database_owned_by;
use t_database_rename_to;
- use t_database_reset_index_storage_parameter;
- use t_database_set_index_storage_parameter;
+ use t_database_reset_storage_parameter;
+ use t_database_set_storage_parameter; // @todo: override the storage parameter to limit/restrict parameters to index storage parameters.
use t_database_set_tablespace;
protected const p_QUERY_COMMAND = 'alter index';
$if_exists = ' ' . $this->p_do_build_if_exists();
}
- $value = $this->name;
+ $value = $this->p_do_build_name();
if (is_string($this->rename_to)) {
$value .= ' ' . $this->p_do_build_rename_to();
}
$if_exists = NULL;
$value = c_database_string::ALL_IN_TABLESPACE . ' ' . $value;
- if (is_array($this->owned_by)) {
+ if (!is_null($this->owned_by)) {
$value .= ' ' . $this->p_do_build_owned_by();
}
<?php
/**
* @file
- * Provides a class for specific Postgesql query: ALTER COALATION.
+ * Provides a class for specific Postgesql query: ALTER LANGUAGE.
*/
namespace n_koopa;
require_once('common/database/classes/database_query.php');
+require_once('common/database/traits/database_name.php');
+require_once('common/database/traits/database_owner_to.php');
+require_once('common/database/traits/database_procedural.php');
+require_once('common/database/traits/database_rename_to.php');
+
/**
- * The class for building and returning a Postgresql ALTER COALATION query string.
+ * The class for building and returning a Postgresql ALTER LANGUAGE query string.
*
* @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html
*/
-class c_database_alter_coalation extends c_database_query {
- protected const p_QUERY_COMMAND = 'alter coalation';
+class c_database_alter_language extends c_database_query {
+ use t_database_name;
+ use t_database_owner_to;
+ use t_database_procedural;
+ use t_database_rename_to;
+
+ protected const p_QUERY_COMMAND = 'alter language';
/**
*/
public function __construct() {
parent::__construct();
+
+ $this->name = NULL;
+ $this->owner_to = NULL;
+ $this->procedural = NULL;
+ $this->rename_to = NULL;
}
/**
* Class destructor.
*/
public function __destruct() {
+ unset($this->name);
+ unset($this->owner_to);
+ unset($this->procedural);
+ unset($this->rename_to);
+
parent::__destruct();
}
return new c_base_return_false();
}
- // @todo
+ $value = $this->p_do_build_name();
+ if (is_string($this->rename_to)) {
+ $value .= ' ' . $this->p_do_build_rename_to();
+ }
+ else if (is_array($this->owner_to)) {
+ $value .= ' ' . $this->p_do_build_owner_to();
+ }
+ else {
+ unset($value);
+ return new c_base_return_false();
+ }
+
+ if (is_bool($this->procedural)) {
+ $this->value = c_database_string::ALTER . ' ' . $this->p_do_build_procedural() . ' ' . c_database_string::LANGUAGE;
+ }
+ else {
+ $this->value = static::p_QUERY_COMMAND;
+ }
- $this->value = static::p_QUERY_COMMAND;
$this->value .= ' ' . $value;
unset($value);
+
+ return new c_base_return_true();
}
}
require_once('common/database/classes/database_query.php');
+require_once('common/database/traits/database_oid.php');
+require_once('common/database/traits/database_owner_to.php');
/**
- * The class for building and returning a Postgresql ALTER COALATION query string.
+ * The class for building and returning a Postgresql ALTER LARGE OBJECT query string.
*
- * @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html
+ * @see: https://www.postgresql.org/docs/current/static/sql-alterlargeobject.html
*/
-class c_database_alter_coalation extends c_database_query {
- protected const p_QUERY_COMMAND = 'alter coalation';
+class c_database_alter_large_object extends c_database_query {
+ use t_database_oid;
+ use t_database_owner_to;
+
+ protected const p_QUERY_COMMAND = 'alter large object';
/**
*/
public function __construct() {
parent::__construct();
+
+ $this->oid = NULL;
+ $this->owner_to = NULL;
}
/**
* Class destructor.
*/
public function __destruct() {
+ unset($this->oid);
+ unset($this->owner_to);
+
parent::__destruct();
}
* Implements do_build().
*/
public function do_build() {
- $this->value = NULL;
+ if (!is_string($this->oid) || !is_array($this->owner_to)) {
+ return new c_base_return_false();
+ }
- // @todo
+ $this->value = static::p_QUERY_COMMAND;
+ $this->value .= ' ' . $this->p_do_build_oid();
+ $this->value .= ' ' . $this->p_do_build_owner_to();
+ unset($value);
return new c_base_return_true();
}
require_once('common/database/classes/database_query.php');
+require_once('common/database/traits/database_all_in_tablespace.php');
+require_once('common/database/traits/database_cluster_on.php');
+require_once('common/database/traits/database_column_reset.php');
+require_once('common/database/traits/database_column_set.php');
+require_once('common/database/traits/database_column_set_statistics.php');
+require_once('common/database/traits/database_column_set_storage.php');
+require_once('common/database/traits/database_depends_on_extension.php');
+require_once('common/database/traits/database_if_exists.php');
+require_once('common/database/traits/database_name.php');
+require_once('common/database/traits/database_no_wait.php');
+require_once('common/database/traits/database_owned_by.php');
+require_once('common/database/traits/database_owner_to.php');
+require_once('common/database/traits/database_rename_column.php');
+require_once('common/database/traits/database_rename_to.php');
+require_once('common/database/traits/database_reset_storage_parameter.php');
+require_once('common/database/traits/database_set_schema.php');
+require_once('common/database/traits/database_set_storage_parameter.php');
+require_once('common/database/traits/database_set_tablespace.php');
+require_once('common/database/traits/database_set_without_cluster.php');
+
/**
- * The class for building and returning a Postgresql ALTER COALATION query string.
+ * The class for building and returning a Postgresql ALTER MATERIALIZED VIEW query string.
*
- * @see: https://www.postgresql.org/docs/current/static/sql-alteraggregate.html
+ * @see: https://www.postgresql.org/docs/current/static/sql-altermaterializedview.html
*/
-class c_database_alter_coalation extends c_database_query {
- protected const p_QUERY_COMMAND = 'alter coalation';
+class c_database_alter_materialized_view extends c_database_query {
+ use t_database_all_in_tablespace;
+ use t_database_cluster_on;
+ use t_database_column_reset;
+ use t_database_column_set;
+ use t_database_column_set_statistics;
+ use t_database_column_set_storage;
+ use t_database_depends_on_extension;
+ use t_database_if_exists;
+ use t_database_name;
+ use t_database_no_wait;
+ use t_database_owned_by;
+ use t_database_owner_to;
+ use t_database_rename_column;
+ use t_database_rename_to;
+ use t_database_reset_storage_parameter;
+ use t_database_set_schema;
+ use t_database_set_storage_parameter;
+ use t_database_set_tablespace;
+ use t_database_set_without_cluster;
+
+ protected const p_QUERY_COMMAND = 'alter materialized view';
/**
*/
public function __construct() {
parent::__construct();
+
+ $this->all_in_tablespace = NULL;
+ $this->cluster_on = NULL;
+ $this->column_reset = NULL;
+ $this->column_set = NULL;
+ $this->column_set_statistics = NULL;
+ $this->column_set_storage = NULL;
+ $this->depends_on_extension = NULL;
+ $this->if_exists = NULL;
+ $this->name = NULL;
+ $this->no_wait = NULL;
+ $this->owned_by = NULL;
+ $this->owner_to = NULL;
+ $this->rename_column = NULL;
+ $this->rename_to = NULL;
+ $this->reset_storage_parameter = NULL;
+ $this->set_schema = NULL;
+ $this->set_storage_parameter = NULL;
+ $this->set_tablespace = NULL;
+ $this->set_without_cluster = NULL;
}
/**
* Class destructor.
*/
public function __destruct() {
+ unset($this->all_in_tablespace);
+ unset($this->cluster_on);
+ unset($this->column_reset);
+ unset($this->column_set);
+ unset($this->column_set_statistics);
+ unset($this->column_set_storage);
+ unset($this->depends_on_extension);
+ unset($this->if_exists);
+ unset($this->name);
+ unset($this->no_wait);
+ unset($this->owner_to);
+ unset($this->owned_by);
+ unset($this->rename_column);
+ unset($this->rename_to);
+ unset($this->reset_storage_parameter);
+ unset($this->set_schema);
+ unset($this->set_storage_parameter);
+ unset($this->set_tablespace);
+ unset($this->set_without_cluster);
+
parent::__destruct();
}
* Implements do_build().
*/
public function do_build() {
- $this->value = NULL;
+ if (!is_string($this->name)) {
+ return new c_base_return_false();
+ }
+
+ $if_exists = NULL;
+ if (is_bool($this->if_exists)) {
+ $if_exists = ' ' . $this->p_do_build_if_exists();
+ }
+
+ $value = $this->p_do_build_name();
+ if (is_string($this->depends_on_extension)) {
+ $value .= ' ' . $this->p_do_build_depends_on_extension();
+ $if_exists = NULL;
+ }
+ else if (is_array($this->rename_column)) {
+ $value .= ' ' . $this->p_do_build_rename_column();
+ }
+ else if (is_string($this->rename_to)) {
+ $value .= ' ' . $this->p_do_build_rename_to();
+ }
+ else if (is_string($this->set_schema)) {
+ $value .= ' ' . $this->p_do_build_set_schema();
+ }
+ else if (is_string($this->set_tablespace)) {
+ $if_exists = NULL;
+ $value = c_database_string::ALL_IN_TABLESPACE . ' ' . $value;
+
+ if (!is_null($this->owned_by)) {
+ $value .= ' ' . $this->p_do_build_owned_by();
+ }
+
+ $value .= ' ' . $this->p_do_build_set_tablespace();
+
+ if (is_bool($this->no_wait)) {
+ $value .= ' ' . $this->p_do_build_no_wait();
+ }
+ }
+ else if (is_array($this->column_set_statistics)) {
+ $value .= ' ' . $this->p_do_build_column_set_statistics();
+ }
+ else if (is_array($this->column_set)) {
+ $value .= ' ' . $this->p_do_build_column_set();
+ }
+ else if (is_array($this->column_reset)) {
+ $value .= ' ' . $this->p_do_build_column_reset();
+ }
+ else if (is_array($this->column_set_storage)) {
+ $value .= ' ' . $this->p_do_build_column_set_storage();
+ }
+ else if (is_string($this->cluster_on)) {
+ $value .= ' ' . $this->p_do_build_cluster_on();
+ }
+ else if (is_string($this->set_without_cluster)) {
+ $value .= ' ' . $this->p_do_build_set_without_cluster();
+ }
+ else if (is_string($this->set_storage_parameter)) {
+ $value .= ' ' . $this->p_do_build_set_storage_parameter();
+ }
+ else if (is_string($this->reset_storage_parameter)) {
+ $value .= ' ' . $this->p_do_build_reset_storage_parameter();
+ }
+ else if (is_string($this->owner_to)) {
+ $value .= ' ' . $this->p_do_build_owner_to();
+ }
+ else {
+ unset($value);
+ unset($if_exists);
+ return new c_base_return_false();
+ }
+
+ $this->value = static::p_QUERY_COMMAND;
+
+ if (is_string($if_exists)) {
+ $this->value .= ' ' . $if_exists;
+ }
+ unset($if_exists);
- // @todo
+ $this->value .= ' ' . $value;
+ unset($value);
return new c_base_return_true();
}
public const AGGREGATE = 'aggregate';
public const ALL = 'all';
public const ALLOW_CONNECTIONS = 'allow_connections';
+ public const ALTER = 'alter';
public const AS = 'as';
public const ASCEND = 'asc';
public const AUTOSUMMARIZE = 'autosummarize';
public const CALLED_ON_NULL_INPUT = 'called on null input';
public const CASCADE = 'cascade';
public const CAST = 'cast';
+ public const CLUSTER_ON = 'cluster on';
public const COLLATION = 'collation';
+ public const COLUMN = 'column';
public const CONNECTION_LIMIT = 'connection limit';
public const CONVERSION = 'conversion';
public const COST = 'cost';
public const ENABLE_TRIGGER = 'enable trigger';
public const EVENT_TRIGGER = 'event trigger';
public const EXECUTE = 'execute';
+ public const EXTENDED = 'extended';
public const EXTERNAL = 'external';
public const FALSE = 'false';
public const FAST_UPDATE = 'fastupdate';
public const LANGUAGE = 'language';
public const LEAKPROOF = 'leakproof';
public const LOG_AUTOVACUUM_MIN_DURATION = 'log_autovacuum_min_duration';
+ public const MAIN = 'main';
public const MATERIALIZED_VIEW = 'materialized view';
+ public const N_DISTINCT = 'n_distinct';
+ public const N_DISTINCT_INHERITED = 'n_distinct_inherited';
public const NO_HANDLER = 'no handler';
public const NO_INHERIT = 'no inherit';
public const NO_VALIDATOR = 'no validator';
- public const NO_WAIT = 'no wait';
+ public const NO_WAIT = 'nowait';
public const NOT_LEAKPROOF = 'not leakproof';
public const NOT_NULL = 'not null';
public const NOT_VALID = 'not valid';
public const PAGES_PER_RANGE = 'pages_per_range';
public const PARALLEL = 'parallel';
public const PARALLEL_WORKERS = 'parallel_workers';
+ public const PLAIN = 'plain';
public const PROCEDURAL = 'procedural';
public const PUBLIC = 'public';
public const REFERENCES = 'references';
public const SET = 'set';
public const SET_DEFAULT = 'set default';
public const SET_SCHEMA = 'set schema';
+ public const SET_STATISTICS = 'set statistics';
+ public const SET_STORAGE = 'set storage';
public const SET_TABLESPACE = 'set tablespace';
public const SET_WITH_OIDS = 'set with oids';
+ public const SET_WITHOUT_CLUSTER = 'set without cluster';
public const SET_WITHOUT_OIDS = 'set without oids';
public const STABLE = 'stable';
public const STRICT = 'strict';
--- /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 option.
+ */
+class e_database_attribute_option {
+ public const NONE = 0;
+ public const N_DISTINCT = 1;
+ public const N_DISTINCT_INHERITED = 2;
+}
/**
* Codes associated with database cascade/restrict.
*/
-class e_database_on {
+class e_database_cascade {
public const NONE = 0;
public const CASCADE = 1;
public const RESTRICT = 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 set storage.
+ */
+class e_database_set_storage {
+ public const NONE = 0;
+ public const EXTENDED = 1;
+ public const EXTERNAL = 2;
+ public const MAIN = 3;
+ public const PLAIN = 4;
+}
public const CURRENT = 1;
public const SESSION = 2;
public const NAME = 3;
+ public const ALL = 4;
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_add_user() {
- if (is_null($this->add_user)) {
- return NULL;
- }
-
$values = [];
foreach ($this->add_user['names'] as $name) {
if ($name === e_database_user::CURRENT) {
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_argument_type() {
- if (is_null($this->argument_type)) {
- return NULL;
- }
-
$values = [];
foreach ($this->argument_type as $argument_type) {
$value = '';
* Set the HANDLER settings.
*
* @param int|null $cascade
- * The intege representing cascade/no-cascade.
+ * The integer representing cascade/no-cascade.
* Set to NULL to disable.
*
* @return c_base_return_status
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_cascade() {
- if (is_null($this->cascade)) {
- return NULL;
- }
-
$value = NULL;
if ($this->cascade['type'] === e_database_cascade::CASCADE) {
if (isset($this->cascade['name'])) {
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * These traits are associated with COLUMN_RESET attribute_option.
+ *
+ * @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_option.php');
+
+/**
+ * Provide the sql COLUMN .. RESET (attribute_option ...) functionality.
+ */
+trait t_database_column_reset {
+ protected $column_reset;
+
+ /**
+ * Set the COLUMN_RESET (attribute_option ...) settings.
+ *
+ * @param int|null $attribute_option
+ * The attribute option code to assign.
+ * Should be one of: e_database_attribute_option.
+ * When both this and $name are NULL, then column reset is disabled.
+ * @param string|null $name
+ * The column name.
+ * Must be specified before any attributes may be assigned.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_column_reset($attribute_option, $name = NULL) {
+ if (is_null($name) && is_null($attribute_option)) {
+ $this->column_reset = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($name) && !isset($this->column_reset['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 ($attribute_option) {
+ case e_database_attribute_option::N_DISTINCT:
+ case e_database_attribute_option::N_DISTINCT_INHERITED:
+ break;
+ default:
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'attribute_option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (is_string($name)) {
+ if (is_array($this->column_reset)) {
+ $this->column_reset['name'] = $name;
+ }
+ else {
+ $this->column_reset = [
+ 'name' => $name,
+ 'values' => [],
+ ];
+ }
+ }
+
+ if (!is_null($attribute_option)) {
+ $this->column_reset['values'][] = $attribute_option;
+ }
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned COLUMN_RESET 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.
+ *
+ * @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).
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_column_reset($index = NULL) {
+ 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[index]', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'column_reset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned on success.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_column_reset() {
+ $values = [];
+ foreach ($this->column_reset['values'] as $attribute_option) {
+ if ($attribute_option === e_database_attribute_option::N_DISTINCT) {
+ $values[] = c_database_string::N_DISTINCT;
+ }
+ else if ($attribute_option === e_database_attribute_option::N_DISTINCT_INHERITED) {
+ $values[] = c_database_string::N_DISTINCT_INHERITED;
+ }
+ }
+ unset($attribute_option);
+
+ return c_database_string::COLUMN . ' ' . $this->column_reset['name'] . ' ' . c_database_string::RESET . ' ' . implode(', ', $values);
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * These traits are associated with SET index attribute_option.
+ *
+ * @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_attribute_option.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql COLUMN .. SET functionality.
+ */
+trait t_database_column_set {
+ protected $column_set;
+
+ /**
+ * Set the SET index (attribute_option ...) settings.
+ *
+ * @param int|null $attribute_option
+ * The attribute option code to assign.
+ * Should be one of: e_database_attribute_option.
+ * When both this and $name are NULL, then column reset is disabled.
+ * @param string|null $value
+ * The value associated with the parameter.
+ * May be NULL only when $attribute_option or $name is NULL.
+ * @param string|null $name
+ * The column name.
+ * Must be specified before any attributes may be assigned.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_column_set($attribute_option, $value = NULL, $name = NULL) {
+ if (is_null($name) && is_null($attribute_option)) {
+ $this->column_set = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($name) && !isset($this->column_set['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 ($attribute_option) {
+ case e_database_attribute_option::N_DISTINCT:
+ case e_database_attribute_option::N_DISTINCT_INHERITED:
+ break;
+ default:
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'attribute_option', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($attribute_option) && !is_string($value)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (is_string($name)) {
+ if (is_array($this->column_set)) {
+ $this->column_set['name'] = $name;
+ }
+ else {
+ $this->column_set = [
+ 'name' => $name,
+ 'values' => [],
+ ];
+ }
+ }
+
+ if (!is_null($attribute_option)) {
+ $this->column_set['values'][] = [
+ 'type' => $attribute_option,
+ 'value' => $value,
+ ];
+ }
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * 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.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing the set index attribute option settings on success.
+ * 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) {
+ 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);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'column_set', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned on success.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_column_set() {
+ $values = [];
+ foreach ($this->column_set['values'] as $attribute_option => $value) {
+ if ($attribute_option === e_database_attribute_option::N_DISTINCT) {
+ $values[] = c_database_string::N_DISTINCT . ' = ' . $value;
+ }
+ else if ($attribute_option === e_database_attribute_option::N_DISTINCT_INHERITED) {
+ $values[] = c_database_string::N_DISTINCT_INHERITED . ' = ' . $value;
+ }
+ }
+ unset($attribute_option);
+ unset($value);
+
+ return c_database_string::COLUMN . ' ' . $this->column_set['name'] . ' ' . c_database_string::SET . ' ' . implode(', ', $values);
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * These traits are associated with actions.
+ *
+ * @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 COLUMN SET STATISTICS functionality.
+ */
+trait t_database_column_set_statistics {
+ protected $column_set_statistics;
+
+ /**
+ * Set the COLUMN .. SET STATISTICS settings.
+ *
+ * @param string|null $name
+ * The column name.
+ * Set to NULL to disable.
+ * @param int|null $value
+ * The integer representing the statistics setting.
+ * May be NULL only when column name is NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_column_set_statistics($name, $value = NULL) {
+ if (is_null($name)) {
+ $this->column_set_storage = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($name)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (is_int($column_set_statistics)) {
+ $this->column_set_statistics = [
+ 'name' => $name,
+ 'value' => $value,
+ ];
+
+ return new c_base_return_true();
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ /**
+ * Get the currently assigned set statistics integer.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing the column_set_statistics setting on success.on success.
+ * NULL is returned if not set (is not to be used).
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_column_set_statistics() {
+ if (is_null($this->column_set_statistics)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->column_set_statistics)) {
+ return c_base_return_array::s_new($this->column_set_statistics);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'column_set_statistics', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned on success.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_column_set_statistics() {
+ return c_database_string::COLUMN . ' ' . $this->column_set_statistics['name'] . ' ' . c_database_string::SET_STATISTICS . ' ' . $this->column_set_statistics['value'];
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * These traits are associated with column set storage.
+ *
+ * @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_column_set_storage.php');
+
+/**
+ * Provide the sql COLUMN .. SET STORAGE functionality.
+ */
+trait t_database_column_set_storage {
+ protected $column_set_storage;
+
+ /**
+ * Set the COLUMN .. SET STORAGE settings.
+ *
+ * @param string|null $name
+ * The column name.
+ * Set to NULL to disable.
+ * @param int|null $type
+ * The integer representing the storage setting.
+ * May be NULL only when column name is NULL.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_column_set_storage($name, $type = NULL) {
+ if (is_null($name)) {
+ $this->column_set_storage = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_string($name)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ switch ($type) {
+ case e_database_set_storage::EXTENDED:
+ case e_database_set_storage::EXTERNAL:
+ case e_database_set_storage::MAIN:
+ case e_database_set_storage::PLAIN:
+ break;
+ default:
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->column_set_storage = [
+ 'type' => $type,
+ 'name' => $name,
+ ];
+
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned column_set_storage.
+ *
+ * @return c_base_return_array|c_base_return_null
+ * An array containing the column_set_storage setting on success.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_column_set_storage() {
+ if (is_null($this->column_set_storage)) {
+ return new c_base_return_null();
+ }
+
+ if (is_array($this->column_set_storage)) {
+ return c_base_return_array::s_new($this->column_set_storage);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'column_set_storage', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned on success.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_column_set_storage() {
+ $value = c_database_string::COLUMN . ' ' . $this->column_set_storage['name'] . ' ' . c_database_string::SET_STORAGE . ' ';
+ if ($this->column_set_storage['type'] === e_database_column_set_storage::EXTENDED) {
+ return $value . c_database_string::EXTENDED;
+ }
+ else if ($this->column_set_storage['type'] === e_database_column_set_storage::EXTERNAL) {
+ return $value . c_database_string::EXTERNAL;
+ }
+ else if ($this->column_set_storage['type'] === e_database_column_set_storage::MAIN) {
+ return $value . c_database_string::MAIN;
+ }
+ else if ($this->column_set_storage['type'] === e_database_column_set_storage::PLAIN) {
+ return $value . c_database_string::PLAIN;
+ }
+ unset($value);
+
+ return NULL;
+ }
+}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_constraint() {
- if (is_null($this->constraint)) {
- return NULL;
- }
-
$value = NULL;
if ($this->constraint['type'] === e_database_constraint::ADD) {
if (is_string($this->constraint['name'])) {
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_depends_on_extension() {
- if (is_null($this->depends_on_extension)) {
- return NULL;
- }
-
return c_database_string::DEPENDS_ON_EXTENSION . ' ' . $this->depends_on_extension;
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_enable_trigger() {
- if (is_null($this->enable_trigger)) {
- return NULL;
- }
-
$value = NULL;
switch ($this->enable_trigger['type']) {
case e_database_enable_trigger::ALWAYS:
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_for_role() {
- if (is_null($this->for_role)) {
- return NULL;
- }
-
return c_database_string::FOR_ROLE . ' ' . implode(', ', $this->for_role);
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_function_action() {
- if (is_null($this->function_action)) {
- return NULL;
- }
-
$values = [];
foreach ($this->function_action as $function_action) {
if ($function_action['type'] === e_database_function_action::CALLED_ON_NULL_INPUT) {
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_grant_option_for() {
- if (is_null($this->grant_option_for)) {
- return NULL;
- }
-
return $this->grant_option_for ? c_database_string::GRANT_OPTION_FOR : NULL;
}
}
* Set the HANDLER settings.
*
* @param int|null $handler
- * The intege representing handler/no-handler.
+ * The integer representing handler/no-handler.
* Set to NULL to disable.
* @param string|null $handler_function
* The handler function name or null when NO_HANDLER is specified.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_handler() {
- if (is_null($this->handler)) {
- return NULL;
- }
-
$value = NULL;
if ($this->handler['type'] === e_database_handler::HANDLER) {
if (isset($this->handler['name'])) {
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_in_schema() {
- if (is_null($this->in_schema)) {
- return NULL;
- }
-
return c_database_string::IN_SCHEMA . ' ' . implode(', ', $this->in_schema);
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_inherit() {
- if (is_null($this->inherit)) {
- return NULL;
- }
-
$value = $this->inherit['inherit'] ? c_database_string::INHERIT : c_database_string::NO_INHERIT;
$value .= ' ' . $this->inherit['name'];
return $value;
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_name() {
- if (is_null($this->name)) {
- return NULL;
- }
-
return $this->name;
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_no_wait() {
- if (is_null($this->no_wait)) {
- return NULL;
- }
-
return $this->no_wait ? c_database_string::NO_WAIT : NULL;
}
}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * These traits are associated with actions.
+ *
+ * @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 NAME functionality.
+ */
+trait t_database_oid {
+ protected $oid;
+
+ /**
+ * Set the OID settings.
+ *
+ * @param string|null $oid
+ * The oid to use.
+ * Set to NULL to disable.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function set_oid($oid) {
+ if (is_null($oid)) {
+ $this->oid = NULL;
+ return new c_base_return_true();
+ }
+
+ if (is_string($oid)) {
+ $this->oid = $oid;
+ return new c_base_return_true();
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'oid', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ /**
+ * Get the currently assigned oid.
+ *
+ * @return c_base_return_string|c_base_return_null
+ * A oid on success.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_oid() {
+ if (is_null($this->oid)) {
+ return new c_base_return_null();
+ }
+
+ if (is_string($this->oid)) {
+ return c_base_return_string::s_new($this->oid);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'oid', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned on success.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_oid() {
+ return $this->oid;
+ }
+}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_on() {
- if (is_null($this->on)) {
- return NULL;
- }
-
$value = NULL;
switch($this->on) {
case e_database_on::TABLES_TO:
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_options() {
- if (is_null($this->options)) {
- return NULL;
- }
-
$options = [];
foreach ($this->options as $options_value) {
if ($options_value['type'] == e_database_options::ADD) {
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_order_by() {
- if (is_null($this->order_by)) {
- return NULL;
- }
-
return c_database_string::ORDER_BY . ' ' . $this->order_by;
}
}
/**
* Assigns the SQL owned_by.
*
- * @param int|null $owned_by
- * Set a owned_by code.
+ * @param int|string|null $owned_by
+ * Set a owned_by code or name.
* Set to NULL to disable.
* When NULL, this will remove all values.
*
}
if (is_int($owned_by)) {
- // no reason to add any owned_by once ALL is present.
- if ($this->owned_by === e_database_owned_by::ALL) {
- return new c_base_return_true();
- }
+ if ($owned_by === e_database_user::ALL) {
+ $this->owned_by = e_database_user::ALL;
- if ($owned_by === e_database_owned_by::ALL) {
- $this->owned_by = e_database_owned_by::ALL;
+ return new c_base_return_true();
}
- else {
- if (!is_array($this->owned_by)) {
- $this->owned_by = [];
- }
-
- $this->owned_by[] = $owned_by;
+ }
+ else if (is_string($owned_by)) {
+ if (!is_array($this->owned_by)) {
+ $this->owned_by = [];
}
- return new c_base_return_true();
+ $this->owned_by[] = $owned_by;
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'owned_by', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
* (optional) Get the owned_by at the specified index.
* When NULL, all owned_by are returned.
*
- * @return c_base_return_int|c_base_return_array|c_base_return_null
+ * @return c_base_return_int|c_base_return_string|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.
}
if (is_null($index)) {
- if ($this->owned_by === e_database_owned_by::ALL) {
+ if ($this->owned_by === e_database_user::ALL) {
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);
}
}
- else {
- if (is_int($index) && array_key_exists($index, $this->owned_by) && is_int($this->owned_by[$index])) {
- return clone($this->owned_by[$index]);
+ 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 (is_string($this->owned_by[$index])) {
+ return c_base_return_string::s_new($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);
}
-
- $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);
}
$error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'owned_by', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_owned_by() {
- if (is_null($this->owned_by)) {
- return NULL;
+ $owned_by = c_database_string::OWNED_BY . ' ';
+
+ if ($this->owned_by === e_database_user::ALL) {
+ $owned_by .= c_database_string::ALL;
+ }
+ else {
+ $owned_by .= implode(', ', $this->owned_by);
}
- return c_database_string::OWNED_BY . ' ' . implode(', ', $this->owned_by);
+ return $owned_by;
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_owner_to() {
- if (is_null($this->owner_to)) {
- return NULL;
- }
-
return c_database_string::OWNER_TO . ' ' . $this->owner_to['value'];
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_privilege() {
- if (is_null($this->privilege)) {
- return NULL;
- }
-
if ($this->privilege === e_database_privilege::ALL) {
return c_database_string::ALL;
}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * These traits are associated with actions.
+ *
+ * @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 PROCEDURAL functionality.
+ */
+trait t_database_procedural {
+ protected $procedural;
+
+ /**
+ * Set the PROCEDURAL value.
+ *
+ * @param bool|null $procedural
+ * Set to TRUE for PROCEDURAL.
+ * Set to FALSE for nothing.
+ * 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_procedural($procedural) {
+ if (is_null($procedural)) {
+ $this->procedural = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_bool($procedural)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'procedural', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->procedural = $procedural;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned with grant option value.
+ *
+ * @return c_base_return_bool|c_base_return_null
+ * TRUE for PROCEDURAL on success.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_procedural() {
+ if (is_null($this->procedural)) {
+ return new c_base_return_null();
+ }
+
+ if (is_bool($this->procedural)) {
+ return c_base_return_bool::s_new($this->procedural);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'procedural', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned on success.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_procedural() {
+ return $this->procedural ? c_database_string::PROCEDURAL : NULL;
+ }
+}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_rename_column() {
- if (is_null($this->rename_column)) {
- return NULL;
- }
-
return c_database_string::RENAME_COLUMN . ' ' . $this->rename_column['from'] . ' ' . c_database_string::TO . $this->rename_column['to'];
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_rename_to() {
- if (is_null($this->rename_to)) {
- return NULL;
- }
-
return c_database_string::RENAME_TO . ' ' . $this->rename_to;
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_reset() {
- if (is_null($this->reset)) {
- return NULL;
- }
-
$value = NULL;
if ($this->reset['type'] === e_database_reset::PARAMETER) {
if (is_string($this->reset['value'])) {
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_reset_storage_parameter() {
- if (is_null($this->reset_storage_parameter)) {
- return NULL;
- }
-
$values = [];
foreach ($this->reset_storage_parameter as $storage_parameter) {
if ($storage_parameter === e_database_storage_parameter::AUTOSUMMARIZE) {
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_restrict() {
- if (is_null($this->restrict)) {
- return NULL;
- }
-
return $this->restrict ? c_database_string::RESTRICT : NULL;
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_role_specification() {
- if (is_null($this->role_specification)) {
- return NULL;
- }
-
$value = NULL;
if (is_string($this->role_specification)) {
$value = $this->role_specification;
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set() {
- if (is_null($this->set)) {
- return NULL;
- }
-
$value = NULL;
if ($this->set['type'] === e_database_set::TO) {
if (is_null($this->set['parameter'])) {
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_schema() {
- if (is_null($this->set_schema)) {
- return NULL;
- }
-
return c_database_string::SET_SCHEMA . ' ' . $this->set_schema;
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_storage_parameter() {
- if (is_null($this->set_storage_parameter)) {
- return NULL;
- }
-
$values = [];
foreach ($this->set_storage_parameter as $storage_parameter => $value) {
if ($storage_parameter === e_database_storage_parameter::AUTOSUMMARIZE) {
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_tablespace() {
- if (is_null($this->set_tablespace)) {
- return NULL;
- }
-
return c_database_string::SET_TABLESPACE . ' ' . $this->set_tablespace;
}
}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_set_with_oids() {
- if (is_null($this->set_with_oids)) {
- return NULL;
- }
-
return $this->set_with_oids ? c_database_string::SET_WITH_OIDS : c_database_string::SET_WITHOUT_OIDS;
}
}
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * These traits are associated with actions.
+ *
+ * @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 SET WITHOUT CLUSTER functionality.
+ */
+trait t_database_set_without_cluster {
+ protected $set_without_cluster;
+
+ /**
+ * Set the SET WITHOUT CLUSTER value.
+ *
+ * @param bool|null $set_without_cluster
+ * Set to TRUE for SET WITHOUT CLUSTER.
+ * Set to FALSE for nothing.
+ * 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_set_without_cluster($set_without_cluster) {
+ if (is_null($set_without_cluster)) {
+ $this->set_without_cluster = NULL;
+ return new c_base_return_true();
+ }
+
+ if (!is_bool($set_without_cluster)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'set_without_cluster', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->set_without_cluster = $set_without_cluster;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the currently assigned with grant option value.
+ *
+ * @return c_base_return_bool|c_base_return_null
+ * TRUE for SET WITHOUT CLUSTER on success.
+ * NULL is returned if not set.
+ * NULL with the error bit set is returned on error.
+ */
+ public function get_set_without_cluster() {
+ if (is_null($this->set_without_cluster)) {
+ return new c_base_return_null();
+ }
+
+ if (is_bool($this->set_without_cluster)) {
+ return c_base_return_bool::s_new($this->set_without_cluster);
+ }
+
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_without_cluster', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+ return c_base_return_error::s_null($error);
+ }
+
+ /**
+ * Perform the common build process for this trait.
+ *
+ * As an internal trait method, the caller is expected to perform any appropriate validation.
+ *
+ * @return string|null
+ * A string is returned on success.
+ * NULL is returned if there is nothing to process or there is an error.
+ */
+ protected function p_do_build_set_without_cluster() {
+ return $this->set_without_cluster ? c_database_string::SET_WITHOUT_CLUSTER : NULL;
+ }
+}
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_to_role() {
- if (is_null($this->to_role)) {
- return NULL;
- }
-
$values = [];
foreach ($this->to_role as $to_role) {
if ($this->to_role['type'] === e_database_role::PUBLIC) {
* Set the VALIDATOR settings.
*
* @param int|null $validator
- * The intege representing validator/no-validator.
+ * The integer representing validator/no-validator.
* Set to NULL to disable.
* @param string|null $validator_function
* The validator function name or null when NO_VALIDATOR is specified.
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_validator() {
- if (is_null($this->validator)) {
- return NULL;
- }
-
$value = NULL;
if ($this->validator['type'] == e_database_validator::VALIDATOR) {
if (isset($this->validator['name'])) {
require_once('common/database/classes/database_string.php');
/**
- * Provide the sql WITH GANT OPTION functionality.
+ * Provide the sql WITH GRANT OPTION functionality.
*/
trait t_database_with_grant_option {
protected $with_grant_option;
* Set the WITH GRANT OPTION value.
*
* @param bool|null $with_grant_option
- * Set to TRUE for WITH GANT OPTION.
+ * Set to TRUE for WITH GRANT OPTION.
* Set to FALSE for nothing.
* Set to NULL to disable.
*
* Get the currently assigned with grant option value.
*
* @return c_base_return_bool|c_base_return_null
- * TRUE for WITH GANT OPTION on success.
+ * TRUE for WITH GRANT OPTION on success.
* NULL is returned if not set.
* NULL with the error bit set is returned on error.
*/
* NULL is returned if there is nothing to process or there is an error.
*/
protected function p_do_build_with_grant_option() {
- if (is_null($this->with_grant_option)) {
- return NULL;
- }
-
return $this->with_grant_option ? c_database_string::WITH_GRANT_OPTION : NULL;
}
}