]> Kevux Git Server - koopa/commitdiff
Cleanup: Rename t_database_set to t_database_set_configuration_parameter
authorKevin Day <thekevinday@gmail.com>
Wed, 16 Jan 2019 01:41:52 +0000 (19:41 -0600)
committerKevin Day <thekevinday@gmail.com>
Wed, 16 Jan 2019 01:42:06 +0000 (19:42 -0600)
common/database/classes/database_alter_database.php
common/database/classes/database_alter_role.php
common/database/classes/database_alter_subscription.php
common/database/classes/database_string.php
common/database/enumerations/database_set.php
common/database/traits/database_connection.php
common/database/traits/database_set_configuration_parameter.php [moved from common/database/traits/database_set.php with 56% similarity]

index 76944393375d6fae7cebbe1244b792a18631ce7e..8d0520b7d04c3551a745a7971a0064b05702706e 100644 (file)
@@ -9,7 +9,7 @@ require_once('common/base/classes/base_error.php');
 require_once('common/base/classes/base_return.php');
 
 require_once('common/database/enumerations/database_reset.php');
-require_once('common/database/enumerations/database_set.php');
+require_once('common/database/enumerations/database_set_configuration_parameter.php');
 
 require_once('common/database/classes/database_query.php');
 require_once('common/database/classes/database_string.php');
@@ -18,7 +18,7 @@ require_once('common/database/traits/database_name.php');
 require_once('common/database/traits/database_rename_to.php');
 require_once('common/database/traits/database_owner_to.php');
 require_once('common/database/traits/database_set_tablespace.php');
-require_once('common/database/traits/database_set.php');
+require_once('common/database/traits/database_set_configuration_parameter.php');
 require_once('common/database/traits/database_reset.php');
 
 /**
@@ -30,7 +30,7 @@ class c_database_alter_database extends c_database_query {
   use t_database_name;
   use t_database_rename_to;
   use t_database_owner_to;
-  use t_database_set;
+  use t_database_set_configuration_parameter;
   use t_database_set_tablespace;
   use t_database_reset;
 
@@ -44,12 +44,12 @@ class c_database_alter_database extends c_database_query {
   public function __construct() {
     parent::__construct();
 
-    $this->name           = NULL;
-    $this->rename_to      = NULL;
-    $this->owner_to       = NULL;
-    $this->set            = NULL;
-    $this->set_tablespace = NULL;
-    $this->reset          = NULL;
+    $this->name                        = NULL;
+    $this->rename_to                   = NULL;
+    $this->owner_to                    = NULL;
+    $this->set_configuration_parameter = NULL;
+    $this->set_tablespace              = NULL;
+    $this->reset                       = NULL;
 
     // TODO: it may be better (and more consistent) to convert option into a trait, just like all of the others.
     $this->option = NULL;
@@ -62,7 +62,7 @@ class c_database_alter_database extends c_database_query {
     unset($this->name);
     unset($this->rename_to);
     unset($this->owner_to);
-    unset($this->set);
+    unset($this->set_configuration_parameter);
     unset($this->set_tablespace);
     unset($this->reset);
 
@@ -101,7 +101,7 @@ class c_database_alter_database extends c_database_query {
    *
    * @return c_base_return_status
    *   TRUE on success, FALSE otherwise.
-   *   FALSE with error bit set is returned on error.
+   *   FALSE with error bit set_configuration_parameter is returned on error.
    */
   public function set_option($option) {
     if (is_null($option)) {
@@ -123,7 +123,7 @@ class c_database_alter_database extends c_database_query {
    *
    * @return c_database_argument_database_option|c_base_return_null
    *   The assigned option or NULL if not defined.
-   *   NULL with the error bit set is returned on error.
+   *   NULL with the error bit set_configuration_parameter is returned on error.
    */
   public function get_option() {
     if (is_null($this->option)) {
@@ -163,8 +163,8 @@ class c_database_alter_database extends c_database_query {
     else if (isset($this->set_tablespace)) {
       $value .= $this->p_do_build_set_tablespace();
     }
-    else if (is_array($this->set)) {
-      $value .= $this->p_do_build_set();
+    else if (is_array($this->set_configuration_parameter)) {
+      $value .= $this->p_do_build_set_configuration_parameter();
     }
     else if (is_array($this->reset)) {
       $value .= $this->p_do_build_reset();
index 2bdf923d73aeca5a9ae479444556866bafc4a5ea..711a2d1555a5bbc25c4e0e67c0b3176a08b0d5ad 100644 (file)
@@ -15,7 +15,7 @@ require_once('common/database/traits/database_name.php');
 require_once('common/database/traits/database_rename_to.php');
 require_once('common/database/traits/database_reset.php');
 require_once('common/database/traits/database_role_specification.php');
-require_once('common/database/traits/database_set.php');
+require_once('common/database/traits/database_set_configuration_parameter.php');
 require_once('common/database/traits/database_with_role_option.php');
 
 
@@ -31,7 +31,7 @@ class c_database_alter_role extends c_database_query {
   use t_database_reset;
   use t_database_role_option;
   use t_database_role_specification;
-  use t_database_set;
+  use t_database_set_configuration_parameter;
 
   protected const p_QUERY_COMMAND = 'alter role';
 
@@ -42,13 +42,13 @@ class c_database_alter_role extends c_database_query {
   public function __construct() {
     parent::__construct();
 
-    $this->in_database        = NULL;
-    $this->name               = NULL;
-    $this->rename             = NULL;
-    $this->reset              = NULL;
-    $this->role_specification = NULL;
-    $this->set                = NULL;
-    $this->with_role_option   = NULL;
+    $this->in_database                 = NULL;
+    $this->name                        = NULL;
+    $this->rename                      = NULL;
+    $this->reset                       = NULL;
+    $this->role_specification          = NULL;
+    $this->set_configuration_parameter = NULL;
+    $this->with_role_option            = NULL;
   }
 
   /**
@@ -60,7 +60,7 @@ class c_database_alter_role extends c_database_query {
     unset($this->rename);
     unset($this->reset);
     unset($this->role_specification);
-    unset($this->set);
+    unset($this->set_configuration_parameter);
     unset($this->with_role_option);
 
     parent::__destruct();
@@ -110,8 +110,8 @@ class c_database_alter_role extends c_database_query {
         $value .= ' ' . $this->p_do_build_in_database();
       }
 
-      if (isset($this->set)) {
-        $value .= ' ' . $this->p_do_build_set();
+      if (isset($this->set_configuration_parameter)) {
+        $value .= ' ' . $this->p_do_build_set_configuration_parameter();
       }
       else if (isset($this->reset)) {
         $value .= ' ' . $this->p_do_build_reset();
index 29bf56e959c07c8d04990a6f1ac8e990465dbe82..37f9cef8813d273cebd85f3771fd5f5ce381c075 100644 (file)
@@ -17,7 +17,7 @@ require_once('common/database/traits/database_name.php');
 require_once('common/database/traits/database_owner_to.php');
 require_once('common/database/traits/database_refresh_publication.php');
 require_once('common/database/traits/database_rename_to.php');
-require_once('common/database/traits/database_set.php');
+require_once('common/database/traits/database_set_configuration_parameter.php');
 require_once('common/database/traits/database_set_publication_name.php');
 require_once('common/database/traits/database_set_schema.php');
 require_once('common/database/traits/database_with_publication_option.php');
@@ -37,7 +37,7 @@ class c_database_alter_subscription extends c_database_query {
   use t_database_owner_to;
   use t_database_refresh_publication;
   use t_database_rename_to;
-  use t_database_set;
+  use t_database_set_configuration_parameter;
   use t_database_set_publication_name;
   use t_database_set_schema;
   use t_database_with_publication_option;
@@ -52,18 +52,18 @@ class c_database_alter_subscription extends c_database_query {
   public function __construct() {
     parent::__construct();
 
-    $this->connection              = NULL;
-    $this->disable                 = NULL;
-    $this->enable                  = NULL;
-    $this->name                    = NULL;
-    $this->owner_to                = NULL;
-    $this->refresh_publication     = NULL;
-    $this->rename_to               = NULL;
-    $this->set                     = NULL;
-    $this->set_publication_name    = NULL;
-    $this->set_schema              = NULL;
-    $this->with_publication_option = NULL;
-    $this->with_refresh_option     = NULL;
+    $this->connection                  = NULL;
+    $this->disable                     = NULL;
+    $this->enable                      = NULL;
+    $this->name                        = NULL;
+    $this->owner_to                    = NULL;
+    $this->refresh_publication         = NULL;
+    $this->rename_to                   = NULL;
+    $this->set_configuration_parameter = NULL;
+    $this->set_publication_name        = NULL;
+    $this->set_schema                  = NULL;
+    $this->with_publication_option     = NULL;
+    $this->with_refresh_option         = NULL;
   }
 
   /**
@@ -77,7 +77,7 @@ class c_database_alter_subscription extends c_database_query {
     unset($this->owner_to);
     unset($this->refresh_publication);
     unset($this->rename_to);
-    unset($this->set);
+    unset($this->set_configuration_parameter);
     unset($this->set_publication_name);
     unset($this->set_schema);
     unset($this->with_publication_option);
@@ -139,8 +139,8 @@ class c_database_alter_subscription extends c_database_query {
     else if (isset($this->disable)) {
       $value .= ' ' . $this->p_do_build_disable();
     }
-    else if (isset($this->set)) {
-      $value .= ' ' . $this->p_do_build_set();
+    else if (isset($this->set_configuration_parameter)) {
+      $value .= ' ' . $this->p_do_build_set_configuration_parameter();
     }
     else if (isset($this->owner_to)) {
       $value .= ' ' . $this->p_do_build_owner_to();
index 373429d693007c7c066fbcf0f3880b0f3e1d7589..73e0b420109244ade6d5f08de635e60e598bb8aa 100644 (file)
@@ -200,6 +200,7 @@ class c_database_string {
   public const TRUNCATE                              = 'truncate';
   public const TYPE                                  = 'type';
   public const TO                                    = 'to';
+  public const TO_DEFAULT                            = 'to default';
   public const UNSAFE                                = 'unsafe';
   public const UPDATE                                = 'update';
   public const USAGE                                 = 'usage';
index a40ea7304701b1caf08aa3e00bae4283b2970624..7138f8a115ea5de607825723fe1be628fbfe189b 100644 (file)
@@ -13,6 +13,7 @@ namespace n_koopa;
 class e_database_set {
   public const NONE         = 0;
   public const TO           = 1;
-  public const EQUAL        = 2;
-  public const FROM_CURRENT = 3;
+  public const TO_DEFAULT   = 2;
+  public const EQUAL        = 3;
+  public const FROM_CURRENT = 4;
 }
index e77f297a801e629e5f46096e9e5c361626dae63c..d5d8060da027abe81ded685598e1b84298d2a012 100644 (file)
@@ -80,6 +80,6 @@ trait t_database_connection {
    *   NULL is returned if there is nothing to process or there is an error.
    */
   protected function p_do_build_connection() {
-    return c_database_string::CONNECTION . ' ' . strval($this->connection);
+    return c_database_string::CONNECTION . ' ' . $this->connection;
   }
 }
similarity index 56%
rename from common/database/traits/database_set.php
rename to common/database/traits/database_set_configuration_parameter.php
index 5aeee772c1701bbeb0fb8897ef08dd8744c44ee6..ae5a225e306c984258a0d3e326c6c795b4a4127b 100644 (file)
@@ -17,13 +17,13 @@ require_once('common/database/classes/database_string.php');
 /**
  * Provide the sql SET functionality.
  */
-trait t_database_set {
-  protected $set;
+trait t_database_set_configuration_parameter {
+  protected $set_configuration_parameter;
 
   /**
-   * Set the SET settings.
+   * Set the SET configuation parameter settings.
    *
-   * @param int|null $set
+   * @param int|null $type
    *   The SET code to assign.
    *   Should be one of: e_database_set.
    *   Set to NULL to disable.
@@ -39,18 +39,18 @@ trait t_database_set {
    *   TRUE on success, FALSE otherwise.
    *   FALSE with the error bit set is returned on error.
    */
-  public function set_set($set, $parameter = NULL, $value = NULL) {
-    if (is_null($set)) {
-      $this->set = NULL;
+  public function set_set_configuration_parameter($type, $parameter = NULL, $value = NULL) {
+    if (is_null($type)) {
+      $this->set_configuration_parameter = NULL;
       return new c_base_return_true();
     }
 
-    if (!is_int($set)) {
-      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'set', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+    if (!is_int($type)) {
+      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
       return c_base_return_error::s_false($error);
     }
 
-    if ($set === e_database_set::TO || $set === e_database_set::EQUAL) {
+    if ($type === e_database_set::TO || $type === e_database_set::EQUAL) {
       if (!is_string($parameter)) {
         $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
         return c_base_return_error::s_false($error);
@@ -66,8 +66,8 @@ trait t_database_set {
         return c_base_return_error::s_false($placeholder->get_error());
       }
 
-      $set = [
-        'type' => $set,
+      $configuration_parameter = [
+        'type' => $type,
         'parameter' => $placeholder,
         'value' => NULL,
       ];
@@ -75,7 +75,7 @@ trait t_database_set {
       if (is_string($value)) {
         $placeholder = $this->add_placeholder($value);
         if ($placeholder->has_error()) {
-          unset($set);
+          unset($configuration_parameter);
           return c_base_return_error::s_false($placeholder->get_error());
         }
 
@@ -83,14 +83,14 @@ trait t_database_set {
         unset($placeholder);
       }
 
-      $this->set = $set;
-      unset($set);
+      $this->set_configuration_parameter = $configuration_parameter;
+      unset($configuration_parameter);
 
       return new c_base_return_true();
     }
-    else if ($set == e_database_set::FROM_CURRENT) {
-      $this->set = [
-        'type' => $set,
+    else if ($type == e_database_set::FROM_CURRENT) {
+      $this->set_configuration_parameter = [
+        'type' => $type,
         'parameter' => NULL,
         'value' => NULL,
       ];
@@ -102,23 +102,23 @@ trait t_database_set {
   }
 
   /**
-   * Get the currently assigned set settings.
+   * Get the currently assigned set configuration parameter settings.
    *
    * @return c_base_return_array|c_base_return_null
-   *   An array containing set settings on success.
+   *   An array containing set configuration parameter settings on success.
    *   NULL is returned if not set (set tablespace is not to be used).
    *   NULL with the error bit set is returned on error.
    */
-  public function get_set() {
-    if (is_null($this->set)) {
+  public function get_set_configuration_parameter() {
+    if (is_null($this->set_configuration_parameter)) {
       return new c_base_return_null();
     }
 
-    if (is_array($this->set)) {
-      return c_base_return_array::s_new($this->set);
+    if (is_array($this->set_configuration_parameter)) {
+      return c_base_return_array::s_new($this->set_configuration_parameter);
     }
 
-    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'set_configuration_parameter', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
     return c_base_return_error::s_null($error);
   }
 
@@ -131,28 +131,31 @@ trait t_database_set {
    *   A string is returned on success.
    *   NULL is returned if there is nothing to process or there is an error.
    */
-  protected function p_do_build_set() {
+  protected function p_do_build_set_configuration_parameter() {
     $value = NULL;
-    if ($this->set['type'] === e_database_set::TO) {
-      $value = c_database_string::SET . ' ' . $this->set['parameter'] . ' ' . c_database_string::TO . ' ';
-      if (is_null($this->set['value'])) {
+    if ($this->set_configuration_parameter['type'] === e_database_set::TO) {
+      $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' ' . c_database_string::TO . ' ';
+      if (is_null($this->set_configuration_parameter['value'])) {
         $value .= c_database_string::DEFAULT;
       }
       else {
-        $value = $this->set['value'];
+        $value = $this->set_configuration_parameter['value'];
       }
     }
-    else if ($this->set['type'] === e_database_set::EQUAL) {
-      $value = c_database_string::SET . ' ' . $this->set['parameter'] . ' = ';
-      if (is_null($this->set['value'])) {
+    else if ($this->set_configuration_parameter['type'] === e_database_set::EQUAL) {
+      $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' = ';
+      if (is_null($this->set_configuration_parameter['value'])) {
         $value .= c_database_string::DEFAULT;
       }
-      else if (isset($this->set['parameter']) && isset($this->set['value'])) {
-        $value .= $this->set['value'];
+      else if (isset($this->set_configuration_parameter['parameter']) && isset($this->set_configuration_parameter['value'])) {
+        $value .= $this->set_configuration_parameter['value'];
       }
     }
-    else if ($this->set['type'] == e_database_set::FROM_CURRENT) {
-      $value = c_database_string::SET . ' ' . $this->set['parameter'] . ' = ' . c_database_string::FROM_CURRENT;
+    else if ($this->set_configuration_parameter['type'] == e_database_set::FROM_CURRENT) {
+      $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' = ' . c_database_string::FROM_CURRENT;
+    }
+    else if ($this->set_configuration_parameter['type'] == e_database_set::TO_DEFAULT) {
+      $value = c_database_string::SET . ' ' . $this->set_configuration_parameter['parameter'] . ' ' . c_database_string::TO_DEFAULT;
     }
 
     return $value;