Overview

Namespaces

  • Ark
    • Database

Classes

  • Connection
  • Model
  • ModelFactory
  • QueryBuilder

Interfaces

  • Exception
  • Overview
  • Namespace
  • Class

Class Model

Model

Namespace: Ark\Database
Located at Model.php
Methods summary
public static array
# config( )

Model configuration

Model configuration

Sub classes should extend this static method

Returns

array
final public static mixed
# getConfig( string $key = null )

Get model configuration

Get model configuration

Parameters

$key

Returns

mixed
public
# getTable( )

Get model table

Get model table

public
# getPK( )

Get model pk

Get model pk

public
# getRelations( )

Get model relations

Get model relations

public static string
# entityNameToDBName( string $class )

Translate class name to table name. example: BlogPost => blog_post Acme\BlogPost => blog_post

Translate class name to table name. example: BlogPost => blog_post Acme\BlogPost => blog_post

Parameters

$class
Class name

Returns

string
public
# __construct( Ark\Database\Connection $db, array $data = [], boolean $isNew = true )

Model constructor

Model constructor

Parameters

$db
$data
$isNew
Is it a new model or a model loaded from database.
public Ark\Database\Model
# setAttribute( $attribute, $value )

Set attribute

Set attribute

Returns

Ark\Database\Model
public Ark\Database\Model
# setAttributes( array $attributes )

Set attributes

Set attributes

Parameters

$attributes

Returns

Ark\Database\Model
public boolean
# isNew( )

Is it a new model

Is it a new model

Returns

boolean
public boolean
# isDirty( )

Is it synced with database

Is it synced with database

Returns

boolean
public mixed
# getRaw( string $key = null )

Get raw data

Get raw data

Parameters

$key

Returns

mixed
public mixed
# get( string $key = null )

Get data

Get data

Parameters

$key

Returns

mixed
Find in dirty data first, return all data if key is not specified
public mixed
# __get( string $key )

Magic method to fetch a model field

Magic method to fetch a model field

Parameters

$key

Returns

mixed
public mixed
# getWithRelation( string $name )

Get a field with relation

Get a field with relation

Parameters

$name

Returns

mixed
public Ark\Database\Model
# getOneToOne( string $target, string $key = null, string $target_key = null )

Has one

Has one

Parameters

$target
target model or @table
$key
$target_key

Returns

Ark\Database\Model
public array
# getOneToMany( string $target, string $key = null, string $target_key = null )

Has many

Has many

Parameters

$target
$key
$target_key

Returns

array
public Ark\Database\Model
# getManyToOne( string $target, string $key = null, string $target_key = null )

Belongs to

Belongs to

Parameters

$target
$key
$target_key

Returns

Ark\Database\Model
public array
# getManyToMany( string $target, string $through, string $key = null, string $target_key = null )

Many to many

Many to many

Parameters

$target
$through
$key
$target_key

Returns

array
protected
# parseThrough( $through )
public Ark\Database\Model
# set( string|array $key, mixed $value = null )

Set data

Set data

Parameters

$key
$value

Returns

Ark\Database\Model
public
# __set( $key, $value )
public
# __isset( $key )
public
# __unset( $key )
protected
# buildPKConditions( )
public integer|boolean
# save( )

Save modified data to db

Save modified data to db

Returns

integer|boolean
public integer|boolean
# delete( )

Delete model

Delete model

Returns

integer|boolean
protected
# beforeSave( )
protected
# afterSave( )
protected
# beforeDelete( )
protected
# afterDelete( )
Properties summary
protected $_db
#
protected array $_data
# array()
protected $_safe
#
protected array $_dirty
# array()
protected $_isNew
#
API documentation generated by ApiGen