class Model

Database Model

Traits

Constants

EVENT_MODEL_AFTER_SAVE

EVENT_MODEL_BEFORE_SAVE

EVENT_MODEL_BEFORE_DELETE

EVENT_MODEL_AFTER_DELETE

FIELD_IS_NULL

$this->find_by_field(Model::IS_NULL)

Properties

Core $mod
protected $model_name

var string Name of this model e.g. category or document

protected $table_name

var string Table name for this model

protected bool $table_use_group_id
protected bool $table_auto_properties
protected string $table_primary_key
protected array $table_primary_compound_key
protected array $properties
protected array $properties_meta
protected array $markers
protected array $properties_null_values
bool|string $class_name
string $render_type
protected int $model_version

Hint your model version, this parameter might affect certain outcomes and behaviours This version string is added for backwards compatibility

protected string $model_default_render_xui

Defines a XUI helper which can be used to display this model in the render() function e.g. use 'thread' to use this xui helper "XELOS\Modules\Forum\UI\Thread" of the models parent module

protected array $render_params

Parameters that will be consigned to the XUI helper

static string $find_by_separators
bool $loaded
bool $saved
protected array $changed
array $cache_function_result
static array $_request_cache

Methods

__call(string $method, array $args = array())

No description

__clone()

Magic Function Object Cloning Make sure object references are cleaned up as each object requires a clean and separate reference

__construct(int|bool $id = false)

No description

mixed
__get(mixed $var)

No description

__isset($name)

No description

mixed
__set(mixed $var, mixed $value)

No description

string
__toString()

String Representation of this object (calls for render method)

mixed
_call_cached_function(string $function, array $args)

Calls the passed function only if it is not cached yet, otherwise the previous cached result will be returned

_scopeAll(Query $Query)

Global named scope scopeAll to use on models to return an unscoped unloaded collection

_scopeDefault(Query $Query)

Load default scopes

mixed
_scopeGroupId(Query $Query)

Applies Group ID Filtering

_scope_by(mixed $fn, mixed $parameters)

Called for scopeby Magic Function Creates a new ModelCollection and applies the passed scope

_scope_custom(mixed $fn)

Called for scope_ Magic Function Creates a new ModelCollection and applies the passed custom scope function

add_formatted_property(string $property, string $format, array $options = array())

Apply lib->format multi_format on passed property. The result will be written to ->[property]_formatted

add_scope_condition(Condition|Query|string $new_condition)

Adds a condition to scope the following find functions

Model[]
all(mixed $params = ['order_by'=>'COL1)

Return all models

clear_cached_functions(string|bool $function = false)

Clears the cache for all functions or a specific one

clear_properties()

No description

array
convert_array_to_conditions(array $params = array())

Convert Assoc Multidimensional Array to Model Conditional Array

int
count_all()

Returns the count of all models

Model[]
count_by_TABLE_COL_and_TABLE_COL2(mixed $COL1_VALUE, mixed $COL2_VALUE)

Returns the count of all models with the specific column value

string|void
debug(bool $show_markers = false, int $mode = 0)

No description

bool
delete()

No description

int
delete_by_TABLE_COL(mixed $COL_VALUE) Delete rows specified by condition and returns the affected rows. NOTE: This does not trigger a delete() function of the model. If required use pluck('delete')

on the desired collection.

void
disable_table_group_id()

Disable the use of the group ID in all queries made

void
enable_table_group_id()

Enable the use of the group ID in all queries made

mixed
find(string $mode = 'all', mixed $conditions = false, mixed $query_params = false)

Find Function to find models using the passed condition

ModelCollection|Model[]
find_all_by_TABLE_COL_and_TABLE_COL2($COL1_VALUE, $COL2_VALUE, $params=['order_by'=>'COL1, 5]] $)

Returns loaded ModelCollection

find_by_TABLE_COL(mixed $COL_VALUE, mixed $params = ['order_by'=>'COL1)

Returns all models with a specific column value. Query params can be e.g. order_by

functionNameToQuery(string $query, array $parameters)

Converts a findby* function name to SQL query.

array
getChangedProperties(bool $returnOldValues = false)

Return properties which have been changed after model was initialized/loaded We know these values have been changed locally, but these changes are NOT necessarily reflecting the DB diff

getCollectionByQuery(string $model_name, array|string $dbquery_result, string $population_mode = 'full', string $post_fill_function = 'update')

No description

array
getDBSchema()

Get DB Schema if available

getModelCollection()

Return a new unscoped model collection for further processing

array
getPropertyMarkers(bool $value_discovery = true)

Return properties and markers

getScopeQuery()

Returns the Query object which is being used for building the query The function creates a new Query object if required to enable lazy loading

string
getScopeQueryConditionSQL()

Returns the WHERE SQL Conditions based on the current Condition Separate function to be able to update scopes at this point in time if needed

array
getTouchedProperties(bool $returnOldValues = false)

Return properties which have been touched/set after model was initialized/loaded We know these values have been set, but they might not have changed

string
get_created_at_formatted()

Return a Formatted DateTime

array
get_db_properties()

Returns all properties which are available as DB field (= can be used as find_by() properties) with its currently known raw value Please note that smartTimeFields (updated_at, created_at) are not converted to mysql-date format

bool|mixed
get_i18n_property(string $property, string $force_language = false)

Return the property translated property value if available

string
get_model_name()

Returns the SQL table of this model (if available)

string|bool
get_model_table_name(string $table_name = null)

Returns the SQL table of this model (if available)

array
get_properties(bool $value_discovery = true)

Returns the complete properties array

array
get_properties_meta(bool|string $field = false)

No description

mixed
get_property(string $property_id, bool $get_raw_value = false)

No description

static mixed|null
get_request_cache(string $key)

Return Cache Entry if it exists

string
get_table_name()

Returns the table name of this model.

string
get_table_primary_key()

No description

string
get_updated_at_formatted()

Return a Formatted DateTime

bool
hasChangedProperties()

No description

bool
hasTouchedProperties()

No description

init(bool $auto_load = true)

Initializes the model

load()

No description

bool
load_from_db(string $table_name, array|bool $key_fields = false)

No description

populate_model_by_query(string $model_name, array|string $dbquery_result, string $population_mode = 'full', string $post_fill_function = 'update') deprecated

No description

array
process_find_query(mixed $select_field, mixed $query_params)

Execute Query of find() function. Can be modified by child class if necessary

void
registerDefaultScope($scopeName)

Registers the passed scope as default scope A default scope is present when the model is being loaded and can be removed using the unscope() function if required The passed scope must be defined in a scope[SCOPE_NAME] function e.g. scopeGroupId

reload_schema()

Reloads the schema of the model

bool
remove_from_db(string $table_name, array $key_fields = null)

No description

null
render()

Generic Renderer

int|bool
save()

No description

int|bool
save_to_db(string $table_name, array $params = array())

No description

bool|array
schema_values(mixed $field_name)

Provides a list of all values allowed for enumerations.

scopeAll()

No description

Model[]
scope_by_TABLE_COL_and_TABLE_COL2(mixed $COL1_VALUE, mixed $COL2_VALUE)

Returns unloaded ModelCollection

void
self() $this find_by_id($id)

No description

void
setModelCollectionReference(ModelCollection $modelCollectionReference)

No description

void
set_properties_from_array(array $input, array|bool $filter = false)

No description

set_property(string|array $property_id, string|bool $property_value = false, bool $no_change = false)

Set a Property. If $property_id is an array and $property_value is false, set_property is called for each element in the array with the array key and value as params.

set_render_params(mixed $params = array())

Sets parameter that will be passed to the XUI helpers

static 
set_request_cache(string $key, mixed $value)

Set Request Cache Entry

void
sortMoveTo(int $id, int $sortTo, array|null $conditions = [])

Sort this element to a specific position

sort_down(int $steps = 1, $params = array())

Decrease Sort Priority (Increases SORT value)

sort_up(int $steps = 1, $params = array())

Increase Sort Priority (Decreases SORT value)

stop_temporary_group_id_overwrite()

Stops the temporary overwrite of the table_group_id

void
temporarily_disable_table_group_id()

Temporarily disable the use of the group ID in all queries made

void
temporarily_enable_table_group_id()

Temporarily enables the use of the group ID in all queries made

string
to_json()

Returns the model as JSON array

string
to_string()

Returns the model as STRING

string
to_xml(array|bool $property_filter = false, bool|DOMDocument $doc = false, DOMElement $parent_element = null)

Returns an XML of all model properties

unscope($scopeName = false)

Removes all scopes (including Default Scopes)

int
update_sort(mixed $id = false, string $direction = 'up', int $steps = 1, array $params = array())

Update the sort property for a given table (Move a record up/down)

string|true
validate(array $fieldErrors)

No description

Details

at line 994
ModelCollection|Model|Model[]|int __call(string $method, array $args = array())

No description

Parameters

string $method

method-name

array $args

params

Return Value

ModelCollection|Model|Model[]|int
  • Returns resource (find...) or affected rows (count..|deleted..)

at line 1544
__clone()

Magic Function Object Cloning Make sure object references are cleaned up as each object requires a clean and separate reference

at line 145
__construct(int|bool $id = false)

No description

Parameters

int|bool $id

Primary ID of the model which should be loaded

at line 963
mixed __get(mixed $var)

No description

Parameters

mixed $var

Return Value

mixed

at line 1601
__isset($name)

No description

Parameters

$name

at line 976
mixed __set(mixed $var, mixed $value)

No description

Parameters

mixed $var
mixed $value

Return Value

mixed

at line 1553
string __toString()

String Representation of this object (calls for render method)

Return Value

string

at line 1032
mixed _call_cached_function(string $function, array $args)

Calls the passed function only if it is not cached yet, otherwise the previous cached result will be returned

Parameters

string $function

method-name

array $args

params

Return Value

mixed

in ScopesTrait at line 81
Query _scopeAll(Query $Query)

Global named scope scopeAll to use on models to return an unscoped unloaded collection

Parameters

Query $Query

Query

Return Value

Query

in ScopesTrait at line 90
Query _scopeDefault(Query $Query)

Load default scopes

Parameters

Query $Query

Return Value

Query

at line 1489
protected mixed _scopeGroupId(Query $Query)

Applies Group ID Filtering

Parameters

Query $Query

Return Value

mixed

in ScopesTrait at line 119
protected ModelCollection _scope_by(mixed $fn, mixed $parameters)

Called for scopeby Magic Function Creates a new ModelCollection and applies the passed scope

Parameters

mixed $fn
mixed $parameters

Return Value

ModelCollection

in ScopesTrait at line 132
protected ModelCollection _scope_custom(mixed $fn)

Called for scope_ Magic Function Creates a new ModelCollection and applies the passed custom scope function

Parameters

mixed $fn

Name of the custom scope - e.g. Active - calls _scopeActive() on the model

Return Value

ModelCollection

at line 823
add_formatted_property(string $property, string $format, array $options = array())

Apply lib->format multi_format on passed property. The result will be written to ->[property]_formatted

Parameters

string $property

Property of models to format

string $format

Format Type (e.g. money, date, ...)

array $options

Additional format options

in ScopesTrait at line 32
ModelCollection add_scope_condition(Condition|Query|string $new_condition)

Adds a condition to scope the following find functions

Parameters

Condition|Query|string $new_condition

Return Value

ModelCollection

at line 36
Model[] all(mixed $params = ['order_by'=>'COL1)

Return all models

Parameters

mixed $params

Return Value

Model[]

at line 1051
clear_cached_functions(string|bool $function = false)

Clears the cache for all functions or a specific one

Parameters

string|bool $function

at line 567
clear_properties()

No description

at line 1228
array convert_array_to_conditions(array $params = array())

Convert Assoc Multidimensional Array to Model Conditional Array

Parameters

array $params

['id'=>1,'type'=>'active']

Return Value

array

["id = 1","type = 'active'"]

at line 36
int count_all()

Returns the count of all models

Return Value

int

at line 36
Model[] count_by_TABLE_COL_and_TABLE_COL2(mixed $COL1_VALUE, mixed $COL2_VALUE)

Returns the count of all models with the specific column value

Parameters

mixed $COL1_VALUE
mixed $COL2_VALUE

Return Value

Model[]

at line 808
string|void debug(bool $show_markers = false, int $mode = 0)

No description

Parameters

bool $show_markers

show markers as well?

int $mode

(0 - print, 1 - return, 2 and 3 - Special PopUps)

Return Value

string|void

at line 375
bool delete()

No description

Return Value

bool

was delete successful?

at line 36
int delete_by_TABLE_COL(mixed $COL_VALUE) Delete rows specified by condition and returns the affected rows. NOTE: This does not trigger a delete() function of the model. If required use pluck('delete')

on the desired collection.

Parameters

mixed $COL_VALUE) Delete rows specified by condition and returns the affected rows. NOTE: This does not trigger a delete() function of the model. If required use pluck('delete'

Return Value

int

at line 1497
void disable_table_group_id()

Disable the use of the group ID in all queries made

Return Value

void

at line 1520
void enable_table_group_id()

Enable the use of the group ID in all queries made

Return Value

void

at line 1094
mixed find(string $mode = 'all', mixed $conditions = false, mixed $query_params = false)

Find Function to find models using the passed condition

Parameters

string $mode

Find mode (all/first/count)

mixed $conditions

Conditions passed as field query string (e.g. 'id=1 and name="TEST"') or as parameter array: First Element contains query, 2..n contain Parameters

mixed $query_params

Further query parameters (e.g. limit, order_by, request_cache)

Return Value

mixed

by_mode [ ALL: ModelCollection; FIRST: Model | boolean false on fail ]

at line 36
ModelCollection|Model[] find_all_by_TABLE_COL_and_TABLE_COL2($COL1_VALUE, $COL2_VALUE, $params=['order_by'=>'COL1, 5]] $)

Returns loaded ModelCollection

Parameters

$COL1_VALUE
$COL2_VALUE
$params=['order_by'=>'COL1
5]] $

Return Value

ModelCollection|Model[]

at line 36
Model find_by_TABLE_COL(mixed $COL_VALUE, mixed $params = ['order_by'=>'COL1)

Returns all models with a specific column value. Query params can be e.g. order_by

Parameters

mixed $COL_VALUE
mixed $params

Return Value

Model

at line 1286
Query functionNameToQuery(string $query, array $parameters)

Converts a findby* function name to SQL query.

Parameters

string $query
array $parameters

Return Value

Query

Returns a Query Object with the relevant WHERE Scopes

at line 1685
array getChangedProperties(bool $returnOldValues = false)

Return properties which have been changed after model was initialized/loaded We know these values have been changed locally, but these changes are NOT necessarily reflecting the DB diff

Parameters

bool $returnOldValues

Return values before change or current value after change?

Return Value

array

['property_key'=>'property_value']

at line 839
ModelCollection getCollectionByQuery(string $model_name, array|string $dbquery_result, string $population_mode = 'full', string $post_fill_function = 'update')

No description

Parameters

string $model_name

Model Name, eg.g. category

array|string $dbquery_result

dbquery Result with one record per model OR SQL query

string $population_mode

Population Mode (full or id) - If set to full all object data will be used to fill the objects, if set to id each model will be initialized with the corresponding record id as parameter

string $post_fill_function

Post-Fill Function is triggered on the each model after an object has been filled with data

Return Value

ModelCollection

Always eturns a model collection

at line 187
array getDBSchema()

Get DB Schema if available

Return Value

array

at line 1066
ModelCollection getModelCollection()

Return a new unscoped model collection for further processing

Return Value

ModelCollection

at line 450
array getPropertyMarkers(bool $value_discovery = true)

Return properties and markers

Parameters

bool $value_discovery

Return Value

array

in ScopesTrait at line 212
Query getScopeQuery()

Returns the Query object which is being used for building the query The function creates a new Query object if required to enable lazy loading

Return Value

Query

in ScopesTrait at line 202
protected string getScopeQueryConditionSQL()

Returns the WHERE SQL Conditions based on the current Condition Separate function to be able to update scopes at this point in time if needed

Return Value

string

at line 1666
array getTouchedProperties(bool $returnOldValues = false)

Return properties which have been touched/set after model was initialized/loaded We know these values have been set, but they might not have changed

Parameters

bool $returnOldValues

Return values before change or current value after change?

Return Value

array

['property_key'=>'property_value']

at line 1472
string get_created_at_formatted()

Return a Formatted DateTime

Return Value

string

at line 479
array get_db_properties()

Returns all properties which are available as DB field (= can be used as find_by() properties) with its currently known raw value Please note that smartTimeFields (updated_at, created_at) are not converted to mysql-date format

Return Value

array

['id'=>'1','example_prop'=>'example_val','created_at'=>'']

at line 1642
bool|mixed get_i18n_property(string $property, string $force_language = false)

Return the property translated property value if available

Parameters

string $property

e.g. title_i18n

string $force_language

FALSE will use current user language, otherwise the passed LOCALE will be used

Return Value

bool|mixed

at line 317
string get_model_name()

Returns the SQL table of this model (if available)

Return Value

string

Full qualified table name e.g. xmi_crm01_contact

at line 296
string|bool get_model_table_name(string $table_name = null)

Returns the SQL table of this model (if available)

Parameters

string $table_name

Simple table without instance or system prefix

Return Value

string|bool

Full qualified table name e.g. xmi_crm01_contact

at line 430
array get_properties(bool $value_discovery = true)

Returns the complete properties array

Parameters

bool $value_discovery

Retrieve all values by get_property access method

Return Value

array

at line 466
array get_properties_meta(bool|string $field = false)

No description

Parameters

bool|string $field

if given returns the meta for that field

Return Value

array

at line 397
mixed get_property(string $property_id, bool $get_raw_value = false)

No description

Parameters

string $property_id

Marker ID

bool $get_raw_value

deactivate Marker-Function gets triggered

Return Value

mixed

Marker Content

at line 1630
static mixed|null get_request_cache(string $key)

Return Cache Entry if it exists

Parameters

string $key

Cache Key

Return Value

mixed|null

at line 287
string get_table_name()

Returns the table name of this model.

Return Value

string

at line 309
string get_table_primary_key()

No description

Return Value

string

Primary Key Field in DB

at line 1481
string get_updated_at_formatted()

Return a Formatted DateTime

Return Value

string

at line 1696
bool hasChangedProperties()

No description

Return Value

bool

at line 1673
bool hasTouchedProperties()

No description

Return Value

bool

at line 199
init(bool $auto_load = true)

Initializes the model

Parameters

bool $auto_load

If set to false the init will NOT TRIGGER load in case of a set primary key property

at line 355
load()

No description

at line 698
protected bool load_from_db(string $table_name, array|bool $key_fields = false)

No description

Parameters

string $table_name

Table Name

array|bool $key_fields

Key fields which should be used as WHERE condition

Return Value

bool

at line 932
ModelCollection|Model[] populate_model_by_query(string $model_name, array|string $dbquery_result, string $population_mode = 'full', string $post_fill_function = 'update') deprecated

deprecated Please use getCollectionByQuery() instead

No description

Parameters

string $model_name

Model Name, eg.g. category

array|string $dbquery_result

dbquery Result with one record per model OR SQL query

string $population_mode

Population Mode (full or id) - If set to full all object data will be used to fill the objects, if set to id each model will be initialized with the corresponding record id as parameter

string $post_fill_function

Post-Fill Function is triggered on the each model after an object has been filled with data

Return Value

ModelCollection|Model[]

empty array if none found and compatibility-mode on (xelos model_version < 1)

at line 1246
protected array process_find_query(mixed $select_field, mixed $query_params)

Execute Query of find() function. Can be modified by child class if necessary

Parameters

mixed $select_field
mixed $query_params

Return Value

array

dbquery Result

in ScopesTrait at line 105
protected void registerDefaultScope($scopeName)

Registers the passed scope as default scope A default scope is present when the model is being loaded and can be removed using the unscope() function if required The passed scope must be defined in a scope[SCOPE_NAME] function e.g. scopeGroupId

Parameters

$scopeName

Return Value

void

at line 160
reload_schema()

Reloads the schema of the model

at line 773
protected bool remove_from_db(string $table_name, array $key_fields = null)

No description

Parameters

string $table_name

Table Name

array $key_fields

Key fields which should be used as WHERE condition

Return Value

bool

at line 1584
null render()

Generic Renderer

Return Value

null

at line 327
int|bool save()

No description

Return Value

int|bool

Integer represents ID of saved record, true for successful modifications (update, delete), false otherwise

at line 584
protected int|bool save_to_db(string $table_name, array $params = array())

No description

Parameters

string $table_name

Table Name

array $params

Return Value

int|bool

Integer represents ID of saved record, true for successful modifications (update, delete), false otherwise

Exceptions

DatabaseException

at line 1266
bool|array schema_values(mixed $field_name)

Provides a list of all values allowed for enumerations.

Returns FALSE if the field in question does not exist Returns TRUE for non enum fields Returns an array for enum fields with all available values

Parameters

mixed $field_name

The name of the field to examine

Return Value

bool|array

in ScopesTrait at line 14
ModelCollection scopeAll()

No description

Return Value

ModelCollection

at line 36
Model[] scope_by_TABLE_COL_and_TABLE_COL2(mixed $COL1_VALUE, mixed $COL2_VALUE)

Returns unloaded ModelCollection

Parameters

mixed $COL1_VALUE
mixed $COL2_VALUE

Return Value

Model[]

at line 36
void self() $this find_by_id($id)

No description

Parameters

) $this find_by_id($id

Return Value

void

in ScopesTrait at line 71
void setModelCollectionReference(ModelCollection $modelCollectionReference)

No description

Parameters

ModelCollection $modelCollectionReference

Return Value

void

at line 550
void set_properties_from_array(array $input, array|bool $filter = false)

No description

Parameters

array $input

Assoc array with field_id=>value

array|bool $filter

Filter array with 1-dim field_id's, only these keys from input will be set

Return Value

void

at line 499
set_property(string|array $property_id, string|bool $property_value = false, bool $no_change = false)

Set a Property. If $property_id is an array and $property_value is false, set_property is called for each element in the array with the array key and value as params.

Parameters

string|array $property_id

Marker ID (Can also be an Array)

string|bool $property_value

Value

bool $no_change

Value return void

at line 1574
set_render_params(mixed $params = array())

Sets parameter that will be passed to the XUI helpers

Parameters

mixed $params

at line 1614
static set_request_cache(string $key, mixed $value)

Set Request Cache Entry

Parameters

string $key
mixed $value

in SortTrait at line 116
void sortMoveTo(int $id, int $sortTo, array|null $conditions = [])

Sort this element to a specific position

Parameters

int $id

The record ID you intend to move, use 0 if your model has not been saved yet and you intend to save it to the given sort

int $sortTo

Move element to this new position, should be > 0

array|null $conditions

Add conditions

Return Value

void

in SortTrait at line 28
sort_down(int $steps = 1, $params = array())

Decrease Sort Priority (Increases SORT value)

Parameters

int $steps
$params

in SortTrait at line 17
sort_up(int $steps = 1, $params = array())

Increase Sort Priority (Decreases SORT value)

Parameters

int $steps
$params

at line 1536
stop_temporary_group_id_overwrite()

Stops the temporary overwrite of the table_group_id

at line 1511
void temporarily_disable_table_group_id()

Temporarily disable the use of the group ID in all queries made

Return Value

void

at line 1528
void temporarily_enable_table_group_id()

Temporarily enables the use of the group ID in all queries made

Return Value

void

at line 1444
string to_json()

Returns the model as JSON array

Return Value

string

Returns model string

at line 1455
string to_string()

Returns the model as STRING

Return Value

string

Returns model as string

at line 1397
string to_xml(array|bool $property_filter = false, bool|DOMDocument $doc = false, DOMElement $parent_element = null)

Returns an XML of all model properties

Parameters

array|bool $property_filter

if given, only the properties in this array are added

bool|DOMDocument $doc

used from model_collection to add this model to an existing structure

DOMElement $parent_element

to add this model as Child, necessary if doc is given

Return Value

string

Returns formatted XML string

in ScopesTrait at line 49
ModelCollection unscope($scopeName = false)

Removes all scopes (including Default Scopes)

Parameters

$scopeName

string|bool Name of named scope to be removed or FALSE to clear all scopes incl. unnamed scopes (e.g. scope_by)

Return Value

ModelCollection

in SortTrait at line 43
protected int update_sort(mixed $id = false, string $direction = 'up', int $steps = 1, array $params = array())

Update the sort property for a given table (Move a record up/down)

Parameters

mixed $id

(The record ID you intend to move )

string $direction

(The direction you want the record to move)

int $steps

(The amount of steps you want the record to move)

array $params

key 'filter' optional conditions passed as a key-value array. Key 'order_by' additional ORDER string append to ORDER BY sort

Return Value

int

new Sort Value

at line 951
string|true validate(array $fieldErrors)

No description

Parameters

array $fieldErrors

Field Errors can be returned via reference as array(array('field'=>$field, 'err_msg'=>$error)) or array($field => $error)

Return Value

string|true

TRUE if everything is correct, String for Error-Message