PHP Class TORM\Model

PHP version 5.5
Author: Eustáquio Rangel ([email protected])
Inheritance: use trait torm\Finders, use trait torm\Storage, use trait Persistence, use trait torm\Errors, use trait torm\Validations, use trait torm\Scopes, use trait HasMany, use trait torm\HasOne, use trait torm\BelongsTo, use trait Sequences, use trait Callbacks, use trait torm\Dirty
Show file Open project: taq/torm

Public Properties

Property Type Description
$connection
$errors
$yaml_file

Public Methods

Method Description
__call ( string $method, mixed $args ) : null Trigger to use object values as methods Like $user->name("john doe"); echo $user->name();
__construct ( array $data = null ) Constructor
__get ( string $attr ) : attribute Trigger to get object values as attributes Like echo $user->name;
__set ( string $attr, mixed $value ) : null Trigger to set object values as attributes Like $user->name = "john doe";
closeCursor ( mixed $stmt ) : null Close cursor
closeCursorBehaviour ( mixed $action ) : null Behaviour to close cursor
executePrepared ( mixed $obj, mixed $values = [] ) : object Execute a prepared statement, trying to get it from cache.
extractColumns ( ) : string Extract table columns string
extractUpdateColumns ( mixed $values ) : string Extract update columns string
extractWhereConditions ( mixed $conditions ) : string Extract where conditions string Just used for testing, to avoid change the function name withou the underline on all code. This is something PHP should change.
extractWhereValues ( mixed $conditions ) : mixed Extract where values from conditions
get ( string $attr, boolean $current = true ) : mixed Get an attribute value
getColumns ( ) : mixed Return columns
getOrder ( ) : string Returns the default order.
getPK ( ) : string Returns the primary key column.
getReversedOrder ( ) : string Returns the inverse order.
getTableName ( string $cls = null ) : string Returns the table name.
hasColumn ( string $column ) : column Check if a column exists
isIgnoringCase ( ) : boolean Check if is ignoring case
is_new ( ) : boolean Tell if its a new object (not saved)
query ( string $sql ) : mixed Run a SQL query
reload ( ) : mixed Reload the current object
resolveConnection ( ) : object Resolve the current connection handle.
set ( string $attr, mixed $value ) : null Set an attribute value
setConnection ( mixed $con, string $env = "development" ) : null Sets a specific connection for the current model
setOrder ( string $order ) : null Set the default order
setPK ( string $pk ) : null Set the primary key column
setTableName ( string $table_name ) : null Set the model's table name

Private Methods

Method Description
_checkLoaded ( ) : boolean Check if the object columns were loaded
_extractClassName ( $cls ) : string Extract namespace from class name
_extractWhereAssociativeConditions ( mixed $conditions, string $cls, string $escape ) : string Extract where conditions string, from an associative array
_extractWhereAssociativeValues ( mixed $conditions ) : mixed Extract values from an associative array
_extractWhereConditions ( mixed $conditions ) : string Extract where conditions string
_extractWhereRegularConditions ( mixed $conditions, string $cls, string $escape ) : string Extract where conditions string, from a regular array
_extractWhereRegularValues ( mixed $conditions ) : mixed Extract values from a regular array
_loadColumns ( ) : null Load column info
_loadNullValues ( ) : null Load null values on row columns. Useful to new objects.
_makeBuilder ( ) : mixed Create a query builder
_resolveRelations ( string $attr ) : null Resolve relations on an attribute, if present
_validateAfterInitialize ( ) : null Validate after initialize

Method Details

__call() public method

Trigger to use object values as methods Like $user->name("john doe"); echo $user->name();
public __call ( string $method, mixed $args ) : null
$method string method
$args mixed arguments
return null

__construct() public method

If data is sent, then it loads columns with it.
public __construct ( array $data = null )
$data array to fill the object

__get() public method

Trigger to get object values as attributes Like echo $user->name;
public __get ( string $attr ) : attribute
$attr string attribute
return attribute value

__set() public method

Trigger to set object values as attributes Like $user->name = "john doe";
public __set ( string $attr, mixed $value ) : null
$attr string attribute
$value mixed value
return null

closeCursor() public static method

Close cursor
public static closeCursor ( mixed $stmt ) : null
$stmt mixed statement
return null

closeCursorBehaviour() public static method

Behaviour to close cursor
public static closeCursorBehaviour ( mixed $action ) : null
$action mixed to use
return null

executePrepared() public static method

Execute a prepared statement, trying to get it from cache.
public static executePrepared ( mixed $obj, mixed $values = [] ) : object
$obj mixed object
$values mixed to use
return object statement

extractColumns() public static method

Extract table columns string
public static extractColumns ( ) : string
return string columns

extractUpdateColumns() public static method

Extract update columns string
public static extractUpdateColumns ( mixed $values ) : string
$values mixed to set columns
return string columns

extractWhereConditions() public static method

Extract where conditions string Just used for testing, to avoid change the function name withou the underline on all code. This is something PHP should change.
public static extractWhereConditions ( mixed $conditions ) : string
$conditions mixed to extract
return string where conditions

extractWhereValues() public static method

Extract where values from conditions
public static extractWhereValues ( mixed $conditions ) : mixed
$conditions mixed to extract values
return mixed $values

get() public method

Get an attribute value
public get ( string $attr, boolean $current = true ) : mixed
$attr string attribute
$current boolean current value
return mixed attribute value

getColumns() public static method

Return columns
public static getColumns ( ) : mixed
return mixed columns

getOrder() public static method

If not specified, returns an empty string.
public static getOrder ( ) : string
return string order

getPK() public static method

Returns the primary key column.
public static getPK ( ) : string
return string primary key

getReversedOrder() public static method

If DESC is specified, returns ASC.
public static getReversedOrder ( ) : string
return string order

getTableName() public static method

If not specified one, get the current class name and pluralize it.
public static getTableName ( string $cls = null ) : string
$cls string class name
return string table name

hasColumn() public static method

Check if a column exists
public static hasColumn ( string $column ) : column
$column string to check
return column key

isIgnoringCase() public static method

Check if is ignoring case
public static isIgnoringCase ( ) : boolean
return boolean ignoring case

is_new() public method

Tell if its a new object (not saved)
public is_new ( ) : boolean
return boolean new or not

query() public static method

Run a SQL query
public static query ( string $sql ) : mixed
$sql string query
return mixed result

reload() public method

Reload the current object
public reload ( ) : mixed
return mixed object

resolveConnection() public static method

Get it from PDO or from the current class.
public static resolveConnection ( ) : object
return object connection

set() public method

Set an attribute value
public set ( string $attr, mixed $value ) : null
$attr string attribute
$value mixed value
return null

setConnection() public static method

Sets a specific connection for the current model
public static setConnection ( mixed $con, string $env = "development" ) : null
$con mixed PDO connection
$env string enviroment
return null

setOrder() public static method

Set the default order
public static setOrder ( string $order ) : null
$order string default
return null

setPK() public static method

Set the primary key column
public static setPK ( string $pk ) : null
$pk string primary key
return null

setTableName() public static method

Set the model's table name
public static setTableName ( string $table_name ) : null
$table_name string table name
return null

Property Details

$connection public static property

public static $connection

$errors public property

public $errors

$yaml_file public static property

public static $yaml_file