PHP Класс Phactory\Sql\Phactory

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_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