Overview

Classes

  • TinyDB
  • TinyDBCommand
  • TinyDBFactory
  • TinyDBModel

Exceptions

  • TinyDBException
  • Overview
  • Class
  • Tree

Class TinyDBModel

Model

Located at tinydb.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
string
$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
string
$class Class name

Returns

string
public
# __construct( TinyDB $db, array $data = array(), mixed $isNew = true )

Model constructor

Model constructor

Parameters

$db
TinyDB
$db
$data
array
$data
$isNew

Boolean

$isNew
public
# setAttribute( mixed $attribute, mixed $value )

Set attribute

Set attribute

public
# setAttributes( array $attributes )

Set attributes(table, pk...)

Set attributes(table, pk...)

Parameters

$attributes
array
$attributes
public
# isNew( )
public
# isDirty( )
public mixed
# getRaw( string $key = null )

Get raw data

Get raw data

Parameters

$key
string
$key

Returns

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

Get data

Get data

Parameters

$key
string
$key

Returns

mixed
Find in dirty data first, return all data if key is not specified
public
# __get( mixed $key )
public
# getWithRelation( mixed $name )
public TinyDBModel
# getOneToOne( string $target, string $key = null, string $target_key = null )

Has one

Has one

Parameters

$target
string
$target target model or @table
$key
string
$key
$target_key
string
$target_key

Returns

TinyDBModel
public array
# getOneToMany( string $target, string $key = null, string $target_key = null )

Has many

Has many

Parameters

$target
string
$target
$key
string
$key
$target_key
string
$target_key

Returns

array
public TinyDBModel
# getManyToOne( string $target, string $key = null, string $target_key = null )

Belongs to

Belongs to

Parameters

$target
string
$target
$key
string
$key
$target_key
string
$target_key

Returns

TinyDBModel
public array
# getManyToMany( string $target, string $through, string $key = null, string $target_key = null )

Many to many

Many to many

Parameters

$target
string
$target
$through
string
$through
$key
string
$key
$target_key
string
$target_key

Returns

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

Set data

Set data

Parameters

$key
string|array
$key
$value
mixed
$value
public
# __set( mixed $key, mixed $value )
public
# __isset( mixed $key )
public
# __unset( mixed $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 mixed $_db
#
protected array $_data array()
#
protected mixed $_safe
#
protected array $_dirty array()
#
protected mixed $_isNew
#
API documentation generated by ApiGen 2.8.0