Overview

Namespaces

  • Ark
    • Database

Classes

  • Connection
  • Model
  • ModelFactory
  • QueryBuilder

Interfaces

  • Exception
  • Overview
  • Namespace
  • Class

Class ModelFactory

Model factory

Namespace: Ark\Database
Located at ModelFactory.php
Methods summary
public
# __construct( $db, $model, $pk = null )
public
# getPK( )

PK getter

PK getter

public
# getTable( )

Table getter

Table getter

public
# with( $with )
public
# buildWith( )
public Ark\Database\Model
# map( array $row )

Map array to model

Map array to model

Parameters

$row

Returns

Ark\Database\Model
public array
# mapModels( array $rows )

Map data rows to model array

Map data rows to model array

Parameters

$rows

Returns

array
public Ark\Database\Model
# create( array $row = array() )

Create a fresh model from array

Create a fresh model from array

Parameters

$row

Returns

Ark\Database\Model
protected array
# buildPKConditions( string|array $pk, mixed $_data )

Build PK condition(multiple pk is also supported)

Build PK condition(multiple pk is also supported)

Parameters

$pk
$_data

Returns

array
public integer
# count( string|array $conditions = '', array $params = array() )

Count with conditions

Count with conditions

Parameters

$conditions
$params

Returns

integer
public integer
# countBy( string $key, mixed $value )

Count by key

Count by key

Parameters

$key
$value

Returns

integer
public
# find( integer $pk )

Find by PK

Find by PK

Parameters

$pk
$id
public
# findAll( )

Find all

Find all

public Ark\Database\Model
# findOne( string|array $conditions, array $params = array() )

Find one model with conditions

Find one model with conditions

Parameters

$conditions
$params

Returns

Ark\Database\Model
Or false on failure
public Ark\Database\Model
# findOneBy( string $key, mixed $value )

Find one model by key

Find one model by key

Parameters

$key
$value

Returns

Ark\Database\Model
Or false on failure
public Ark\Database\Model
# findByPK( string|array $pk )

Find one model by primary key

Find one model by primary key

Parameters

$pk

Returns

Ark\Database\Model
Or false on failure
public array
# findMany( string|array $conditions = '', array $params = array(), string|array $orderBy = null, integer $limit = null, integer $offset = null )

Find many models with conditions

Find many models with conditions

Parameters

$conditions
$params
$orderBy
$limit
$offset

Returns

array
Or false on failure
public array
# findManyBy( string $key, mixed $value, string|array $orderBy = null, integer $limit = null, integer $offset = null )

Find many models with by key

Find many models with by key

Parameters

$key
$value
$orderBy
$limit
$offset

Returns

array
Or false on failure
public integer|boolean
# update( array $values, string|array $conditions = '', array $params = array() )

Update table with condition

Update table with condition

Parameters

$values
$conditions
$params

Returns

integer|boolean
public integer|boolean
# updateBy( string $key, mixed $value, array $values )

Update table by key

Update table by key

Parameters

$key
$value
$values

Returns

integer|boolean
public integer|boolean
# updateByPK( string|array $pk, array $values )

Update table by primary key

Update table by primary key

Parameters

$pk
$values

Returns

integer|boolean
public integer|boolean
# insert( array $values )

Insert

Insert

Parameters

$values

Returns

integer|boolean
public integer|boolean
# delete( string|array $conditions = '', array $params = array() )

Delete with condition

Delete with condition

Parameters

$conditions
$conditioins
$params

Returns

integer|boolean
public integer|boolean
# deleteBy( string $key, mixed $value )

Delete by key

Delete by key

Parameters

$key
$value

Returns

integer|boolean
public integer|boolean
# deleteByPK( string|array $pk )

Delete by primary key

Delete by primary key

Parameters

$pk

Returns

integer|boolean
public mixed
# __call( string $name, array $arguments )

Override __call magic method to provide many helper methods

Override __call magic method to provide many helper methods

Parameters

$name
$arguments

Returns

mixed
Properties summary
protected $db
#
protected $modelClass
#
protected $table
#
protected $pk
#
protected $with
#
API documentation generated by ApiGen