PHP 클래스 Phactory\Sql\Phactory

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

보호된 프로퍼티들

프로퍼티 타입 설명
$_blueprints * Array of table name => Blueprint
$_pdo * PDO database connection

공개 메소드들

메소드 설명
__construct ( PDO $pdo ) Constructs a Phactory object for testing SQL databases
build ( $table, $overrides = [] ) * Build a Row object, optionally overriding some or all of the default values.
buildWithAssociations ( $blueprint_name, $associations = [], $overrides = [] ) * Build a Row object, optionally overriding some or all of the default values.
create ( $table, $overrides = [] ) * Instantiate a row in the specified table, optionally overriding some or all of the default values.
createWithAssociations ( $blueprint_name, $associations = [], $overrides = [] ) * Instantiate a row in the specified table, optionally overriding some or all of the default values.
define ( $blueprint_name, $defaults = [], $associations = [] ) * Define the default values to use when constructing a row in the specified table.
defineBlueprint ( $blueprint_name, $defaults = [], $associations = [] ) * alias for define per @jblotus pull request eventually we should just rename the original function
get ( $table_name, $byColumns ) * Get a row from the database as a Row.
getAll ( $table_name, $byColumns )
getConnection ( ) * Get the PDO database connection object.
manyToMany ( $to_table, $join_table, $from_column = null, $from_join_column = null, $to_join_column = null, $to_column = null )
manyToOne ( $to_table, $from_column = null, $to_column = null ) * Create a many-to-one association object for use in define().
oneToOne ( $to_table, $from_column, $to_column = null ) * Create a one-to-one association object for use in define().
recall ( ) * Delete created Row objects from the database.
reset ( ) * Delete created objects from the database, clear defined blueprints, and clear stored inflection exceptions.
setConnection ( $pdo ) * Set the PDO object to use for database connection.
setInflection ( $singular, $plural ) * Specify an exception for table name inflection.

메소드 상세

__construct() 공개 메소드

Constructs a Phactory object for testing SQL databases
public __construct ( PDO $pdo )
$pdo PDO A PDO database connection to test with

build() 공개 메소드

The row is not saved to the database.
public build ( $table, $overrides = [] )
$table name of the table
$overrides key => value pairs of column => value

buildWithAssociations() 공개 메소드

The row is not saved to the database.
public buildWithAssociations ( $blueprint_name, $associations = [], $overrides = [] )
$blueprint_name name of the blueprint to use
$associations [table name] => [Row]
$overrides key => value pairs of column => value

create() 공개 메소드

The row is saved to the database, and returned as a Row.
public create ( $table, $overrides = [] )
$table name of the table
$overrides key => value pairs of column => value

createWithAssociations() 공개 메소드

The row is saved to the database, and returned as a Row.
public createWithAssociations ( $blueprint_name, $associations = [], $overrides = [] )
$blueprint_name name of the blueprint to use
$associations [table name] => [Row]
$overrides key => value pairs of column => value

define() 공개 메소드

* Define the default values to use when constructing a row in the specified table.
public define ( $blueprint_name, $defaults = [], $associations = [] )
$blueprint_name singular name of the table in the database
$defaults key => value pairs of column => value, or a phactory_blueprint
$associations array of phactory_associations

defineBlueprint() 공개 메소드

* alias for define per @jblotus pull request eventually we should just rename the original function
public defineBlueprint ( $blueprint_name, $defaults = [], $associations = [] )

get() 공개 메소드

$byColumn is like array('id' => 123).
public get ( $table_name, $byColumns )
$table_name name of the table

getAll() 공개 메소드

public getAll ( $table_name, $byColumns )

getConnection() 공개 메소드

* Get the PDO database connection object.
public getConnection ( )

manyToMany() 공개 메소드

public manyToMany ( $to_table, $join_table, $from_column = null, $from_join_column = null, $to_join_column = null, $to_column = null )

manyToOne() 공개 메소드

* Create a many-to-one association object for use in define().
public manyToOne ( $to_table, $from_column = null, $to_column = null )
$to_table the table to associate with
$from_column the fk column on the left table
$to_column the pk column of the right table, or null to autodetect

oneToOne() 공개 메소드

* Create a one-to-one association object for use in define().
public oneToOne ( $to_table, $from_column, $to_column = null )
$to_table the table to associate with
$from_column the fk column on the left table
$to_column the pk column of the right table, or null to autodetect

recall() 공개 메소드

* Delete created Row objects from the database.
public recall ( )

reset() 공개 메소드

* Delete created objects from the database, clear defined blueprints, and clear stored inflection exceptions.
public reset ( )

setConnection() 공개 메소드

* Set the PDO object to use for database connection.
public setConnection ( $pdo )
$pdo PDO object

setInflection() 공개 메소드

For example, if your table of fish is called 'fishes', call setInflection('fish', 'fishes')
public setInflection ( $singular, $plural )
$singular singular form of the word.
$plural plural form of the word.

프로퍼티 상세

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

* Array of table name => Blueprint
protected $_blueprints

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

* PDO database connection
protected $_pdo