PHP 클래스 phpDataMapper_Base, phpDataMapper

파일 보기 프로젝트 열기: vlucas/phpDataMapper 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_adapter Stored adapter connections
$_adapterRead
$_collectionClass
$_datasource Data source setup info
$_entityClass Class Names for required classes - Here so they can be easily overridden
$_errors Array of error messages and types
$_exceptionClass
$_fields Store cached field info
$_primaryKey
$_queryClass
$_queryLog Query log
$_relations

공개 메소드들

메소드 설명
__construct ( phpDataMapper_Adapter_Interface $adapter, $adapterRead = null ) Constructor Method
adapter ( ) Get current adapter object
adapterRead ( ) Get adapter object that will serve as the 'slave' for reads
all ( array $conditions = [] ) Find records with given conditions If all parameters are empty, find all records
collectionClass ( ) : string Get collection class name to use
datasource ( ) Get name of the data source
debug ( $entity = null ) Prints all executed SQL queries - useful for debugging
delete ( mixed $conditions ) Delete items matching given conditions
dropDatasource ( ) Drop/delete data source Destructive and dangerous - drops entire data source and all data
entityClass ( ) : string Get entity class name to use
error ( string $field, mixed $msg ) Add an error to error messages array
errors ( $msgs = null ) : array Get array of error messages
fieldExists ( $field ) Check if field exists in defined fields
fields ( ) : array Get formatted fields with all neccesary array keys and values.
first ( array $conditions = [] ) Find first record matching given conditions
get ( $primaryKeyValue ) Load record from primary key
getEntityRelationWithValues ( phpDataMapper_Entity $entity ) Replace entity value placeholders on relation definitions Currently replaces 'entity.[col]' with the column value from the passed entity object
getRelationsFor ( phpDataMapper_Entity $entity ) Load defined relations
getResultSet ( $stmt ) Get result set for given PDO Statement
hasErrors ( string $field = null ) : boolean Check if any errors exist
init ( ) Initialization function, run immediately after __construct() so that the constructor is never overridden
insert ( mixed $entity ) Insert record
isEmpty ( mixed $value ) : boolean Check if a value is empty, excluding 0 (annoying PHP issue)
loadClass ( $className ) Attempt to load class file based on phpDataMapper naming conventions
logQuery ( string $sql, array $data = null ) Log query
migrate ( ) Migrate table structure changes from model to database
primaryKey ( phpDataMapper_Entity $entity ) Get value of primary key for given row result
primaryKeyField ( ) Get value of primary key for given row result
query ( string $sql, array $binds = [] ) Find records with custom SQL query
queryClass ( ) : string Get query class name to use
queryCount ( ) : integer Get count of all queries that have been executed
relations ( ) Get defined relations
save ( mixed $entity ) Save record Will update if primary key found, insert if not Performs validation automatically before saving record
select ( mixed $fields = "*" ) Begin a new database query - get query builder Acts as a kind of factory to get the current adapter's query builder object
truncateDatasource ( ) Truncate data source Should delete all rows and reset serial/auto_increment keys to 0
update ( phpDataMapper_Entity $entity ) Update given row object
validate ( phpDataMapper_Entity $entity ) Run set validation rules on fields

보호된 메소드들

메소드 설명
saveRelatedRowsFor ( $entity, array $fillData = [] ) Save related rows of data

메소드 상세

__construct() 공개 메소드

Constructor Method
public __construct ( phpDataMapper_Adapter_Interface $adapter, $adapterRead = null )
$adapter phpDataMapper_Adapter_Interface

adapter() 공개 메소드

Get current adapter object
public adapter ( )

adapterRead() 공개 메소드

Get adapter object that will serve as the 'slave' for reads
public adapterRead ( )

all() 공개 메소드

Find records with given conditions If all parameters are empty, find all records
public all ( array $conditions = [] )
$conditions array Array of conditions in column => value pairs

collectionClass() 공개 메소드

Get collection class name to use
public collectionClass ( ) : string
리턴 string

datasource() 공개 메소드

Get name of the data source
public datasource ( )

debug() 공개 메소드

Prints all executed SQL queries - useful for debugging
public debug ( $entity = null )

delete() 공개 메소드

Delete items matching given conditions
public delete ( mixed $conditions )
$conditions mixed Array of conditions in column => value pairs or Entity object

dropDatasource() 공개 메소드

Drop/delete data source Destructive and dangerous - drops entire data source and all data
public dropDatasource ( )

entityClass() 공개 메소드

Get entity class name to use
public entityClass ( ) : string
리턴 string

error() 공개 메소드

Add an error to error messages array
public error ( string $field, mixed $msg )
$field string Field name that error message relates to
$msg mixed Error message text - String or array of messages

errors() 공개 메소드

Get array of error messages
public errors ( $msgs = null ) : array
리턴 array

fieldExists() 공개 메소드

Check if field exists in defined fields
public fieldExists ( $field )

fields() 공개 메소드

Merges defaults with defined field values to ensure all options exist for each field.
public fields ( ) : array
리턴 array Defined fields plus all defaults for full array of all possible options

first() 공개 메소드

Find first record matching given conditions
public first ( array $conditions = [] )
$conditions array Array of conditions in column => value pairs

get() 공개 메소드

Load record from primary key
public get ( $primaryKeyValue )

getEntityRelationWithValues() 공개 메소드

Replace entity value placeholders on relation definitions Currently replaces 'entity.[col]' with the column value from the passed entity object
public getEntityRelationWithValues ( phpDataMapper_Entity $entity )
$entity phpDataMapper_Entity

getRelationsFor() 공개 메소드

Load defined relations
public getRelationsFor ( phpDataMapper_Entity $entity )
$entity phpDataMapper_Entity

getResultSet() 공개 메소드

Get result set for given PDO Statement
public getResultSet ( $stmt )

hasErrors() 공개 메소드

Check if any errors exist
public hasErrors ( string $field = null ) : boolean
$field string OPTIONAL field name
리턴 boolean

init() 공개 메소드

Initialization function, run immediately after __construct() so that the constructor is never overridden
public init ( )

insert() 공개 메소드

Insert record
public insert ( mixed $entity )
$entity mixed Entity object or array of field => value pairs

isEmpty() 공개 메소드

Check if a value is empty, excluding 0 (annoying PHP issue)
public isEmpty ( mixed $value ) : boolean
$value mixed
리턴 boolean

loadClass() 공개 정적인 메소드

Attempt to load class file based on phpDataMapper naming conventions
public static loadClass ( $className )

logQuery() 공개 정적인 메소드

Log query
public static logQuery ( string $sql, array $data = null )
$sql string
$data array

migrate() 공개 메소드

Migrate table structure changes from model to database
public migrate ( )

primaryKey() 공개 메소드

Get value of primary key for given row result
public primaryKey ( phpDataMapper_Entity $entity )
$entity phpDataMapper_Entity

primaryKeyField() 공개 메소드

Get value of primary key for given row result
public primaryKeyField ( )

query() 공개 메소드

Find records with custom SQL query
public query ( string $sql, array $binds = [] )
$sql string SQL query to execute
$binds array Array of bound parameters to use as values for query

queryClass() 공개 메소드

Get query class name to use
public queryClass ( ) : string
리턴 string

queryCount() 공개 메소드

Get count of all queries that have been executed
public queryCount ( ) : integer
리턴 integer

relations() 공개 메소드

Get defined relations
public relations ( )

save() 공개 메소드

Save record Will update if primary key found, insert if not Performs validation automatically before saving record
public save ( mixed $entity )
$entity mixed Entity object or array of field => value pairs

saveRelatedRowsFor() 보호된 메소드

Save related rows of data
protected saveRelatedRowsFor ( $entity, array $fillData = [] )
$fillData array

select() 공개 메소드

Begin a new database query - get query builder Acts as a kind of factory to get the current adapter's query builder object
public select ( mixed $fields = "*" )
$fields mixed String for single field or array of fields

truncateDatasource() 공개 메소드

Truncate data source Should delete all rows and reset serial/auto_increment keys to 0
public truncateDatasource ( )

update() 공개 메소드

Update given row object
public update ( phpDataMapper_Entity $entity )
$entity phpDataMapper_Entity

validate() 공개 메소드

Run set validation rules on fields
public validate ( phpDataMapper_Entity $entity )
$entity phpDataMapper_Entity

프로퍼티 상세

$_adapter 보호되어 있는 프로퍼티

Stored adapter connections
protected $_adapter

$_adapterRead 보호되어 있는 프로퍼티

protected $_adapterRead

$_collectionClass 보호되어 있는 프로퍼티

protected $_collectionClass

$_datasource 보호되어 있는 프로퍼티

Data source setup info
protected $_datasource

$_entityClass 보호되어 있는 프로퍼티

Class Names for required classes - Here so they can be easily overridden
protected $_entityClass

$_errors 보호되어 있는 프로퍼티

Array of error messages and types
protected $_errors

$_exceptionClass 보호되어 있는 프로퍼티

protected $_exceptionClass

$_fields 보호되어 있는 프로퍼티

Store cached field info
protected $_fields

$_primaryKey 보호되어 있는 프로퍼티

protected $_primaryKey

$_queryClass 보호되어 있는 프로퍼티

protected $_queryClass

$_queryLog 보호되어 있는 정적으로 프로퍼티

Query log
protected static $_queryLog

$_relations 보호되어 있는 프로퍼티

protected $_relations