The $append is a convenience variable that does not need to exist.
If an array needs to be reset, one shoud call the function with NULL before adding anything new.
/**
* Assign an allowed http method.
*
- * @param int $method
+ * @param int|null $method
* The id of the method to allow.
- * @param bool $append
- * (optional) When TRUE, the method id is appended.
- * When FALSE, the array is re-created with $method as the only array value.
+ * When NULL, the allowed_methods array is reset to an empty array.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
*/
- public function set_allowed_method($method, $append = TRUE) {
- if (!is_int($method)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'method', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ public function set_allowed_method($method) {
+ if (is_null($method)) {
+ $this->allowed_methods = [];
+ return new c_base_return_true();
}
- if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ if (!is_int($method)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'method', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
- if (!$append) {
+ if (!is_array($this->allowed_methods)) {
$this->allowed_methods = [];
}
/**
* Assign cookies.
*
- * @param c_base_cookie $cookie
+ * @param c_base_cookie|null $cookie
* The cookie to assign.
- * @param bool $append
- * (optional) When TRUE the $cookie is appended.
- * When FALSE, the array is reset with $cookie as the only value in the array.
+ * When NULL, the cookies array is reset to an empty array.
*
* @return c_base_return_status
* TRUE is returned on success.
* FALSE with error bit set is returned on error.
*/
- public function set_cookies($cookie, $append = TRUE) {
- if (!($cookie instanceof c_base_cookie)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'cookie', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ public function set_cookies($cookie) {
+ if (is_null($cookie)) {
+ $this->cookies = [];
+ return new c_base_return_true();
}
- if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+ if (!($cookie instanceof c_base_cookie)) {
+ $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'cookie', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
return c_base_return_error::s_false($error);
}
- if (!$append || !is_array($this->cookies)) {
+ if (!is_array($this->cookies)) {
$this->cookies = [];
}
* @param c_database_argument_aggregate_signature|null $aggregate_signature
* The aggregate signatures to use.
* Set to NULL to disable.
- * When NULL, this will remove all aggregate signatures regardless of the $append parameter.
- * @param bool $append
- * (optional) When TRUE, the aggregate signatures will be appended.
- * When FALSE, any existing aggregate signatures will be cleared before appending the aggregate signature.
+ * When NULL, this will remove all values.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
*/
- public function set_aggregate_signature($aggregate_signature, $append = TRUE) {
+ public function set_aggregate_signature($aggregate_signature) {
if (is_null($aggregate_signature)) {
$this->aggregate_signatures = NULL;
return new c_base_return_true();
}
- if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
if ($aggregate_signature instanceof c_database_argument_aggregate_signature) {
- if ($append) {
- if (!is_array($this->aggregate_signatures)) {
- $this->aggregate_signatures = [];
- }
-
- $this->aggregate_signatures[] = $aggregate_signature;
- }
- else {
- $this->aggregate_signatures = [$aggregate_signature];
+ if (!is_array($this->aggregate_signatures)) {
+ $this->aggregate_signatures = [];
}
+ $this->aggregate_signatures[] = $aggregate_signature;
return new c_base_return_true();
}
* @param c_database_argument_aggregate_signature_base|null $order_by_signature
* The order by aggregate signature to use.
* Set to NULL to disable.
- * When NULL, this will remove all modes regardless of the $append parameter.
- * @param bool $append
- * (optional) When TRUE, the argument mode will be appended.
- * When FALSE, any existing aggregate signatures will be cleared before appending the aggregate signature.
+ * When NULL, this will remove all values.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
*/
- public function set_order_by_signature($order_by_signature, $append = TRUE) {
+ public function set_order_by_signature($order_by_signature) {
if (is_null($order_by_signature)) {
$this->order_by_signature = NULL;
return new c_base_return_true();
}
- if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
if ($order_by_signature instanceof c_database_argument_aggregate_signature_base) {
- if ($append) {
- if (!is_array($this->order_by_signature)) {
- $this->order_by_signatures = [];
- }
-
- $this->order_by_signatures[] = $order_by_signature;
- }
- else {
- $this->order_by_signatures = [$order_by_signature];
+ if (!is_array($this->order_by_signature)) {
+ $this->order_by_signatures = [];
}
+ $this->order_by_signatures[] = $order_by_signature;
return new c_base_return_true();
}
* The for role target to use.
* Set to TRUE to use (only) the current role, $append is considered FALSE.
* Set to NULL to disable.
- * When NULL, this will remove all for role targets regardless of the $append parameter.
- * @param bool $append
- * (optional) When TRUE, the for role target will be appended.
- * When FALSE, any existing for role targets will be cleared before appending the for role target.
+ * When NULL, this will remove all values.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
*/
- public function set_for_role_targets($target, $append = TRUE) {
+ public function set_for_role_targets($target) {
if (is_null($target)) {
$this->target = NULL;
return new c_base_return_true();
}
if (is_string($target)) {
- if ($append) {
- if (!is_array($this->for_role_targets)) {
- $this->for_role_targets = [];
- }
-
- $this->for_role_targets[] = $target;
- }
- else {
- $this->for_role_targets = [$target];
+ if (!is_array($this->for_role_targets)) {
+ $this->for_role_targets = [];
}
+ $this->for_role_targets[] = $target;
+
return new c_base_return_true();
}
else if ($target === TRUE) {
* @param int|null $privilege
* Whether or not to use the ON operation in the query.
* Set to NULL to disable.
- * When NULL, this will remove all privileges regardless of the $append parameter.
- * @param bool $append
- * (optional) When TRUE, the aggregate signatures will be appended.
- * When FALSE, any existing aggregate signatures will be cleared before appending the aggregate signature.
+ * When NULL, this will remove all values.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
*/
- public function set_privilege($privilege, $append = TRUE) {
+ public function set_privilege($privilege) {
if (is_null($privilege)) {
$this->privileges = NULL;
return new c_base_return_true();
}
- if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
if (is_int($privilege)) {
- if ($append) {
- if (!is_array($this->privilege)) {
- $this->privileges = [];
- }
-
- $this->privileges[] = $privilege;
- }
- else {
- $this->privileges = [$privilege];
+ if (!is_array($this->privilege)) {
+ $this->privileges = [];
}
+ $this->privileges[] = $privilege;
return new c_base_return_true();
}
* @param c_database_argument_role_name|null $role_name
* The role name to use.
* Set to NULL to disable.
- * When NULL, this will remove all role names regardless of the $append parameter.
- * @param bool $append
- * (optional) When TRUE, the role name will be appended.
- * When FALSE, any existing role names will be cleared before appending the role name.
+ * When NULL, this will remove all values.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
*/
- public function set_role_name($role_name, $append = TRUE) {
+ public function set_role_name($role_name) {
if (is_null($role_name)) {
$this->role_names = NULL;
return new c_base_return_true();
}
- if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
if ($role_name instanceof c_database_argument_role_name) {
- if ($append) {
- if (!is_array($this->role_names)) {
- $this->role_names = [];
- }
-
- $this->role_names[] = $role_name;
- }
- else {
- $this->role_names = [$role_name];
+ if (!is_array($this->role_names)) {
+ $this->role_names = [];
}
+ $this->role_names[] = $role_name;
return new c_base_return_true();
}
* @param string|null $schema_name
* The schema name to use.
* Set to NULL to disable.
- * When NULL, this will remove all schema names regardless of the $append parameter.
- * @param bool $append
- * (optional) When TRUE, the schema name will be appended.
- * When FALSE, any existing schema names will be cleared before appending the schema name.
+ * When NULL, this will remove all values.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
*/
- public function set_in_schema($schema_name, $append = TRUE) {
+ public function set_in_schema($schema_name) {
if (is_null($schema_name)) {
$this->in_schema = NULL;
return new c_base_return_true();
}
- if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
if (is_string($schema_name)) {
- if ($append) {
- if (!is_array($this->in_schema)) {
- $this->in_schema = [];
- }
-
- $this->in_schema[] = $schema_name;
- }
- else {
- $this->in_schema = [$schema_name];
+ if (!is_array($this->in_schema)) {
+ $this->in_schema = [];
}
+ $this->in_schema[] = $schema_name;
return new c_base_return_true();
}
* @param string|null $options_type
* The option type to use.
* Set to NULL to disable.
- * When NULL, this will remove all options regardless of the $append parameter.
+ * When NULL, this will remove all values.
* @param string $value
* The value to associate with the options_type.
* When options_type is NULL, this is ignored.
- * @param bool $append
- * (optional) When TRUE, the schema name will be appended.
- * When FALSE, any existing schema names will be cleared before appending the schema name.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
*/
- public function set_options($options_type, $value, $append = TRUE) {
+ public function set_options($options_type, $value) {
if (is_null($options_type)) {
$this->options = NULL;
return new c_base_return_true();
return c_base_return_error::s_false($error);
}
- if (!is_bool($append)) {
- $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'append', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
- }
-
switch ($options_type) {
case e_database_options::ADD:
case e_database_options::DROP:
return c_base_return_error::s_false($error);
};
- $options = [
+ if (!is_array($this->options)) {
+ $this->options = [];
+ }
+
+ $this->options[] = [
'type' => $options_type,
'value' => $value,
];
- if ($append) {
- if (!is_array($this->options)) {
- $this->options = [];
- }
-
- $this->options[] = $options;
- }
- else {
- $this->options = [$options];
- }
- unset($options);
-
return new c_base_return_true();
}