Overview

Namespaces

  • MvcCore
    • Ext
      • Auth
        • Virtual
      • Debug
        • Tracy
      • Form
        • Core
        • Validators
      • Request
      • Router
        • Lang
      • View
        • Helpers
  • None

Classes

  • Config
  • Controller
  • Debug
  • Model
  • Request
  • Response
  • Route
  • Router
  • Session
  • Tool
  • View
  • Overview
  • Namespace
  • Class
  • Tree

Class Model

Core model - reading 'db' section from system config.ini - database PDO connecting by config settings and index - instance loaded variables initializing - instance initialized values reading - virtual calls/sets and gets handling

Direct known subclasses

MvcCore\Ext\Auth\Virtual\User

Indirect known subclasses

MvcCore\Ext\Auth\User
Abstract
Namespace: MvcCore
Located at mvccore/src/MvcCore/Model.php
Methods summary
public array
# GetValues( boolean $getNullValues = FALSE, boolean $includeInheritProperties = TRUE, boolean $publicOnly = TRUE )

Collect all model class public and inherit field values into array

Collect all model class public and inherit field values into array

Parameters

$getNullValues
if true, include also values with NULLs, by default - FALSE
$includeInheritProperties
if true, include only fields from current model class and from parent classes
$publicOnly
if true, include only public model fields

Returns

array
public MvcCore\Model
# SetUp( array $data = array(), boolean $keysInsensitive = FALSE, boolean $includeInheritProperties = TRUE, boolean $publicOnly = TRUE )

Set up given $data items into $this instance context as typed properties by PHP doc comments, as properties with the same names as $data array keys - case sesitively by default. Do not set any $data items which are not declared in $this context.

Set up given $data items into $this instance context as typed properties by PHP doc comments, as properties with the same names as $data array keys - case sesitively by default. Do not set any $data items which are not declared in $this context.

Parameters

$data
collection with data to set up
$keysInsensitive
if true, set up properties from $data with case insensivity
$includeInheritProperties
if true, include only fields from current model class and from parent classes
$publicOnly
if true, include only public model fields

Returns

MvcCore\Model
public static MvcCore\Model|mixed
# GetInstance( )

Returns (or creates and holds) instance from local store

Returns (or creates and holds) instance from local store

Returns

MvcCore\Model|mixed
public static MvcCore\Model
# GetResource( array $args = array(), string $modelClassName = '', string $resourceClassPath = '\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 __construct() method
$modelClassName
$modelClassPath
$resourceClassPath

Returns

MvcCore\Model
(|\MvcCore\Model\Resource)
public
# __construct( integer $connectionIndex = -1 )

Creates an instance and inits cfg, db and resource properties

Creates an instance and inits cfg, db and resource properties

Parameters

$connectionIndex
public
# Init( integer $connectionIndex = -1 )

Creates an instance and inits cfg, db and resource properties

Creates an instance and inits cfg, db and resource properties

Parameters

$connectionIndex
public static PDO
# GetDb( integer $connectionIndex = -1 )

Returns database connection by connection index (cached by local store) or create new connection of no connection cached.

Returns database connection by connection index (cached by local store) or create new connection of no connection cached.

Parameters

$connectionIndex

Returns

PDO
public static object
# GetCfg( integer $connectionIndex = -1 )

Returns database config by connection index as stdClass (cached by local store)

Returns database config by connection index as stdClass (cached by local store)

Parameters

$connectionIndex

Returns

object
protected static
# loadConfigs( )

Initialize configuration data

Initialize configuration data

Throws

Exception
public mixed|MvcCore\Model
# __call( string $rawName, array $arguments = array() )

Sets any custom property ('PropertyName') by $model->SetPropertyName('value'), which is not necessary to define previously or gets previously defined property ('PropertyName') by $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 $model instance for set.

Sets any custom property ('PropertyName') by $model->SetPropertyName('value'), which is not necessary to define previously or gets previously defined property ('PropertyName') by $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 $model instance for set.

Parameters

$rawName
$arguments

Returns

mixed|MvcCore\Model

Throws

Exception
public
# __set( string $name, mixed $value )

Set any custom property, not necessary to previously define.

Set any custom property, not necessary to previously define.

Parameters

$name
$value
public mixed
# __get( string $name )

Get any custom property, not necessary to previously define, if property is not defined, NULL is returned.

Get any custom property, not necessary to previously define, if property is not defined, NULL is returned.

Parameters

$name

Returns

mixed
Properties summary
protected static array $connectionArguments

PDO connection arguments.

PDO connection arguments.

If you need to reconfigure connection string for any other special PDO database implementation or you specific needs, patch this array in extended application base model class in base __construct method by: static::$connectionArguments = array_merge(static::$connectionArguments, array(...)); or by: static::$connectionArguments['driverName]['dsn'] = '...';

Every key in this field shoud be driver name, you can use: - 4D, cubrid, firebird, ibm, informix, mysql, oci, pgsql, sqlite, sqlsrv (mssql), sysbase, dblib (cubrid, oci, pgsql, sysbase and dblib shoud be used with defaults)

Every value in this field shoud be defined as: - connection query - as first PDO contructor argument with database config replacements. - required to use database credentials for connecting - any additional arguments array

# array( '4D' => array( 'dsn' => '{driver}:host={host};charset=UTF-8', 'auth' => TRUE, 'fileDb' => FALSE, 'options' => array(), ), 'firebird' => array( 'dsn' => '{driver}:host={host};dbname={dbname};charset=UTF8', 'auth' => TRUE, 'fileDb' => TRUE, 'options' => array() ), 'ibm' => array( 'dsn' => 'ibm:DRIVER={IBM DB2 ODBC DRIVER};DATABASE={dbname};HOSTNAME={host};PORT={port};PROTOCOL=TCPIP;', 'auth' => TRUE, 'fileDb' => FALSE, 'options' => array(), ), 'informix' => array( 'dsn' => '{driver}:host={host};service={service};database={dbname};server={server};protocol={protocol};EnableScrollableCursors=1', 'auth' => TRUE, 'fileDb' => FALSE, 'options' => array(), ), 'mysql' => array( 'dsn' => '{driver}:host={host};dbname={dbname}', 'auth' => TRUE, 'fileDb' => FALSE, 'options' => array( '\PDO::ATTR_EMULATE_PREPARES' => FALSE, // let params inserting on database '\PDO::MYSQL_ATTR_MULTI_STATEMENTS' => TRUE, '\PDO::MYSQL_ATTR_INIT_COMMAND' => "SET NAMES 'UTF8'", ), ), 'sqlite' => array( 'dsn' => '{driver}:{dbname}', 'auth' => FALSE, 'fileDb' => TRUE, 'options' => array(), ), 'sqlsrv' => array( 'dsn' => '{driver}:Server={host};Database={dbname}', 'auth' => TRUE, 'fileDb' => FALSE, 'options' => array(), ), 'default' => array( 'dsn' => '{driver}:host={host};dbname={dbname}', 'auth' => TRUE, 'fileDb' => FALSE, 'options' => array(), ), )
protected static integer $connectionIndex

Default database connection index, in config ini defined in section db.defaultDbIndex = 0. In extended classes - use this for connection index of current model if different.

Default database connection index, in config ini defined in section db.defaultDbIndex = 0. In extended classes - use this for connection index of current model if different.

# -1
protected static array $connections

PDO connections array, keyed by connection indexes from system config

PDO connections array, keyed by connection indexes from system config

# array()
protected static array $instances

Instance of current class if there is necessary to use it as singleton

Instance of current class if there is necessary to use it as singleton

# array()
protected static array $configs

System config sections array with stdClass objects, keyed by connection indexes

System config sections array with stdClass objects, keyed by connection indexes

# array()
protected boolean $autoInit

Automaticly initialize config, db connection and resource class

Automaticly initialize config, db connection and resource class

# TRUE
protected PDO $db

PDO instance

PDO instance

#
protected stdClass $cfg

System config section for database under called connection index in constructor

System config section for database under called connection index in constructor

#
protected MvcCore\Model $resource

Resource model class with SQL statements

Resource model class with SQL statements

#
MvcCore API documentation generated by ApiGen