Methods summary
public static
MvcCore\Model
|
#
GetResource( array|null $args = [], string $resourceClassPath = '%SELF%s\Resource' )
Returns (or creates if necessary) model resource instance.
Returns (or creates if necessary) model resource instance.
Parameters
- $args
- Values array with variables to pass into resource
__construct() method.
- $resourceClassPath
- Automatically initialized with string replaced with
%SELF% by static::class (or by get_called_class() ).
Returns
|
public static
stdClass
|
#
GetSysConfigProperties( )
Return system configuration file database section properties names.
Return system configuration file database section properties names.
Returns
stdClass
|
public static
PDO
|
#
GetConnection( string|integer|array|stdClass|null $connectionNameOrConfig = NULL, boolean $strict = TRUE )
Returns \PDO database connection by connection name/index,
usually by system config values (cached by local store)
or create new connection if no connection cached.
Returns \PDO database connection by connection name/index,
usually by system config values (cached by local store)
or create new connection if no connection cached.
Parameters
- $connectionNameOrConfig
- $strict
If TRUE and no connection under given name or given
index found, exception is thrown. TRUE by default.
If FALSE , there could be returned connection by
first available configuration.
Returns
PDO
Throws
InvalidArgumentException
|
public static
stdClass[]
&
|
#
GetConfigs( )
Get all known database connection config records as indexed/named array with \stdClass objects.
Keys in array are connection config names/indexes and \stdClass values are config values.
Get all known database connection config records as indexed/named array with \stdClass objects.
Keys in array are connection config names/indexes and \stdClass values are config values.
Returns
stdClass[]
|
public static
boolean
|
#
SetConfigs( array $configs = [], string|integer $defaultConnectionName,… )
Set all known configuration at once, optionally set default connection name/index.
Example:
\MvcCore\Model::SetConfigs([
// connection name: 'mysql-cdcol':
'mysql-cdcol' => [
'driver' => 'mysql', 'host' => 'localhost',
'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
],
// connection name: 'mssql-tests':
'mssql-tests' => [
'driver' => 'sqlsrv', 'host' => '.\SQLEXPRESS',
'user' => 'sa', 'password' => '1234', 'database' => 'tests',
]
]);
or:
\MvcCore\Model::SetConfigs([
// connection index: 0:
[
'driver' => 'mysql', 'host' => 'localhost',
'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
],
// connection index: 1:
[
'driver' => 'sqlsrv', 'host' => '.\SQLEXPRESS',
'user' => 'sa', 'password' => '1234', 'database' => 'tests',
]
]);
Set all known configuration at once, optionally set default connection name/index.
Example:
\MvcCore\Model::SetConfigs([ // connection name: 'mysql-cdcol': 'mysql-cdcol' => [ 'driver' => 'mysql', 'host' => 'localhost', 'user' => 'root', 'password' => '1234', 'database' => 'cdcol', ], // connection name: 'mssql-tests': 'mssql-tests' => [ 'driver' => 'sqlsrv', 'host' => '.\SQLEXPRESS', 'user' => 'sa', 'password' => '1234', 'database' => 'tests', ]
]);
or:
\MvcCore\Model::SetConfigs([ // connection index: 0: [ 'driver' => 'mysql', 'host' => 'localhost', 'user' => 'root', 'password' => '1234', 'database' => 'cdcol', ], // connection index: 1: [ 'driver' => 'sqlsrv', 'host' => '.\SQLEXPRESS', 'user' => 'sa', 'password' => '1234', 'database' => 'tests', ]
]);
Parameters
- $configs
- Configuration array with
\stdClass objects or arrays with configuration data.
- $defaultConnectionName,…
Returns
boolean
|
public static
stdClass
&
|
#
GetConfig( integer|string|null $connectionName = NULL )
Returns database connection config by connection index (integer)
or by connection name (string) as \stdClass (cached by local store).
Returns database connection config by connection index (integer)
or by connection name (string) as \stdClass (cached by local store).
Parameters
Returns
stdClass
|
public static
string|integer
|
#
SetConfig( array $config = [], string|integer|null $connectionName = NULL )
Set configuration array with optional connection name/index.
If there is array key name or index inside config array or \stdClass ,
it's value is used for connection name or index or there is no param $connectionName defined.
Example:
\MvcCore\Model::SetConfig(array(
'name' => 'mysql-cdcol',
'driver' => 'mysql', 'host' => 'localhost',
'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
));
or:
\MvcCore\Model::SetConfig(array(
'index' => 0,
'driver' => 'mysql', 'host' => 'localhost',
'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
));
or:
\MvcCore\Model::SetConfig(array(
'driver' => 'mysql', 'host' => 'localhost',
'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
), 'mysql-cdcol');
or:
\MvcCore\Model::SetConfig(array(
'driver' => 'mysql', 'host' => 'localhost',
'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
), 0);
Set configuration array with optional connection name/index.
If there is array key name or index inside config array or \stdClass ,
it's value is used for connection name or index or there is no param $connectionName defined.
Example:
\MvcCore\Model::SetConfig(array( 'name' => 'mysql-cdcol', 'driver' => 'mysql', 'host' => 'localhost', 'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
));
or:
\MvcCore\Model::SetConfig(array( 'index' => 0, 'driver' => 'mysql', 'host' => 'localhost', 'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
));
or:
\MvcCore\Model::SetConfig(array( 'driver' => 'mysql', 'host' => 'localhost', 'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
), 'mysql-cdcol');
or:
\MvcCore\Model::SetConfig(array( 'driver' => 'mysql', 'host' => 'localhost', 'user' => 'root', 'password' => '1234', 'database' => 'cdcol',
), 0);
Parameters
Returns
string|integer
|
public
array
|
#
GetValues( integer $propsFlags = 0, boolean $getNullValues = FALSE )
Collect all model class properties values into array.
Result keys could be converted by any conversion flag.
Collect all model class properties values into array.
Result keys could be converted by any conversion flag.
Parameters
- $propsFlags
All properties flags are available except flags:
- \MvcCore\IModel::PROPS_INITIAL_VALUES ,
- \MvcCore\IModel::PROPS_CONVERT_CASE_INSENSITIVE ,
- \MvcCore\IModel::PROPS_NAMES_BY_* .
- $getNullValues
If TRUE , include also values with NULL s,
FALSE by default.
Returns
array
Throws
InvalidArgumentException
|
public
MvcCore\Model
|
#
SetValues( array $data = [], integer $propsFlags = 0 )
Set up given $data items into $this instance context
as typed properties by PHP types (or by PhpDocs comments in PHP < 7.4)
as properties with the same names as $data array keys or converted
by properties flags. Case sensitivelly by default.
Any $data items, which are not declared in $this context are
initialized by __set() method.
Set up given $data items into $this instance context
as typed properties by PHP types (or by PhpDocs comments in PHP < 7.4)
as properties with the same names as $data array keys or converted
by properties flags. Case sensitivelly by default.
Any $data items, which are not declared in $this context are
initialized by __set() method.
Parameters
- $data
- Raw data from database (row) or from form fields.
- $propsFlags
- All properties flags are available.
Returns
Throws
InvalidArgumentException
|
public
array
|
#
GetTouched( integer $propsFlags = 0 )
Get touched properties from $this context.
Touched properties are properties with different value than value under
property name key in $this->initialValues (initial array is optionally
completed in SetValues() method). Result keys could be converted by any
conversion flag.
Get touched properties from $this context.
Touched properties are properties with different value than value under
property name key in $this->initialValues (initial array is optionally
completed in SetValues() method). Result keys could be converted by any
conversion flag.
Parameters
- $propsFlags
All properties flags are available except flags:
- \MvcCore\IModel::PROPS_INITIAL_VALUES ,
- \MvcCore\IModel::PROPS_CONVERT_CASE_INSENSITIVE .
Returns
array
Throws
InvalidArgumentException
|
public
mixed|MvcCore\Model
|
#
__call( string $rawName, array $arguments = [] )
Sets any custom property "PropertyName" by \MvcCore\Model::SetPropertyName("value") ,
which is not necessary to define previously or gets previously defined
property "PropertyName" by \MvcCore\Model::GetPropertyName(); .
Throws exception if no property defined by get call
or if virtual call begins with anything different from Set or Get .
This method returns custom value for get and \MvcCore\Model instance for set.
Sets any custom property "PropertyName" by \MvcCore\Model::SetPropertyName("value") ,
which is not necessary to define previously or gets previously defined
property "PropertyName" by \MvcCore\Model::GetPropertyName(); .
Throws exception if no property defined by get call
or if virtual call begins with anything different from Set or Get .
This method returns custom value for get and \MvcCore\Model instance for set.
Parameters
Returns
Throws
InvalidArgumentException If strtolower($rawName) doesn't begin with "get" or with "set" .
|
public
boolean
|
#
__set( string $name, mixed $value )
Set any custom property, not necessary to previously defined.
Set any custom property, not necessary to previously defined.
Parameters
Returns
boolean
Throws
InvalidArgumentException If name is initialValues or any custom name in extended class.
|
public
mixed
|
#
__get( string $name )
Get any custom property, not necessary to previously defined,
if property is not defined, NULL is returned.
Get any custom property, not necessary to previously defined,
if property is not defined, NULL is returned.
Parameters
Returns
mixed
Throws
InvalidArgumentException If name is initialValues or any custom name in extended class.
|
public
string[]
|
#
__sleep( )
Collect all properties names to serialize them by serialize() method.
Collect all instance properties declared as private, protected and public
and if there is configured in static::$protectedProperties anything as
TRUE (under key by property name), also return those properties in
result array.
Collect all properties names to serialize them by serialize() method.
Collect all instance properties declared as private, protected and public
and if there is configured in static::$protectedProperties anything as
TRUE (under key by property name), also return those properties in
result array.
Returns
string[]
|