PHP Class phpDataMapper_Adapter_PDO, phpDataMapper

Inheritance: implements phpDataMapper_Adapter_Interface
Mostrar archivo Open project: vlucas/phpDataMapper

Protected Properties

Property Type Description
$connection Connection details
$database
$format_date Format for date columns, formatted for PHP's date() function
$format_datetime
$format_time
$host
$options
$password
$username

Public Methods

Method Description
__construct ( mixed $host, string $database = null, string $username = null, string $password = null, array $options = [] ) : void
connection ( ) : object Get database connection
create ( $source, array $data ) Create new row object with set properties
createDatabase ( $database ) Create a database Will throw errors if user does not have proper permissions
dateFormat ( ) : string Get database format
dateTimeFormat ( ) : string Get database format
delete ( string $source, array $data ) Delete entities matching given conditions
dropDatabase ( $database ) Drop a database table Destructive and dangerous - drops entire table and all data Will throw errors if user does not have proper permissions
dropDatasource ( $source ) Drop a database table Destructive and dangerous - drops entire table and all data
dsn ( ) : string Get DSN string for PDO to connect with
escape ( string $string ) Escape/quote direct user input
migrate ( String $table, array $fields ) Migrate table structure changes to database
migrateTableCreate ( $table, array $formattedFields ) Execute a CREATE TABLE command
migrateTableUpdate ( $table, array $formattedFields ) Execute an ALTER/UPDATE TABLE command
prepare ( $sql ) Prepare an SQL statement
read ( phpDataMapper_Query $query ) Build a select statement in SQL Can be overridden by adapters for custom syntax
statementBinds ( array $conditions = [] ) Returns array of binds to pass to query function
statementConditions ( array $conditions = [] ) Builds an SQL string given conditions
statementFields ( array $fields = [] ) Return fields as a string for a query statement
timeFormat ( ) : string Get database time format
toCollection ( phpDataMapper_Query $query, $stmt ) Return result set for current query
truncateDatasource ( $source ) Truncate a database table Should delete all rows and reset serial/auto_increment keys to 0
update ( $source, array $data, array $where = [] ) Update entity

Protected Methods

Method Description
bindValues ( PDOStatement $stmt, array $binds ) Bind array of field/value data to given statement

Method Details

__construct() public method

public __construct ( mixed $host, string $database = null, string $username = null, string $password = null, array $options = [] ) : void
$host mixed Host string or pre-existing PDO object
$database string Optional if $host is PDO object
$username string Optional if $host is PDO object
$password string Optional if $host is PDO object
$options array
return void

bindValues() protected method

Bind array of field/value data to given statement
protected bindValues ( PDOStatement $stmt, array $binds )
$stmt PDOStatement
$binds array

connection() public method

Get database connection
public connection ( ) : object
return object PDO

create() public method

Create new row object with set properties
public create ( $source, array $data )
$data array

createDatabase() public method

Create a database Will throw errors if user does not have proper permissions
public createDatabase ( $database )

dateFormat() public method

Get database format
public dateFormat ( ) : string
return string Date format for PHP's date() function

dateTimeFormat() public method

Get database format
public dateTimeFormat ( ) : string
return string DateTime format for PHP's date() function

delete() public method

Delete entities matching given conditions
public delete ( string $source, array $data )
$source string Name of data source
$data array

dropDatabase() public method

Drop a database table Destructive and dangerous - drops entire table and all data Will throw errors if user does not have proper permissions
public dropDatabase ( $database )

dropDatasource() public method

Drop a database table Destructive and dangerous - drops entire table and all data
public dropDatasource ( $source )

dsn() public method

Get DSN string for PDO to connect with
public dsn ( ) : string
return string

escape() public method

Escape/quote direct user input
public escape ( string $string )
$string string

migrate() public method

Migrate table structure changes to database
public migrate ( String $table, array $fields )
$table String Table name
$fields array Fields and their attributes as defined in the mapper

migrateTableCreate() public method

Execute a CREATE TABLE command
public migrateTableCreate ( $table, array $formattedFields )
$formattedFields array

migrateTableUpdate() public method

Execute an ALTER/UPDATE TABLE command
public migrateTableUpdate ( $table, array $formattedFields )
$formattedFields array

prepare() public method

Prepare an SQL statement
public prepare ( $sql )

read() public method

Build a select statement in SQL Can be overridden by adapters for custom syntax
public read ( phpDataMapper_Query $query )
$query phpDataMapper_Query

statementBinds() public method

Returns array of binds to pass to query function
public statementBinds ( array $conditions = [] )
$conditions array

statementConditions() public method

Builds an SQL string given conditions
public statementConditions ( array $conditions = [] )
$conditions array

statementFields() public method

Return fields as a string for a query statement
public statementFields ( array $fields = [] )
$fields array

timeFormat() public method

Get database time format
public timeFormat ( ) : string
return string Time format for PHP's date() function

toCollection() public method

Return result set for current query
public toCollection ( phpDataMapper_Query $query, $stmt )
$query phpDataMapper_Query

truncateDatasource() public method

Truncate a database table Should delete all rows and reset serial/auto_increment keys to 0
public truncateDatasource ( $source )

update() public method

Update entity
public update ( $source, array $data, array $where = [] )
$data array
$where array

Property Details

$connection protected_oe property

Connection details
protected $connection

$database protected_oe property

protected $database

$format_date protected_oe property

Format for date columns, formatted for PHP's date() function
protected $format_date

$format_datetime protected_oe property

protected $format_datetime

$format_time protected_oe property

protected $format_time

$host protected_oe property

protected $host

$options protected_oe property

protected $options

$password protected_oe property

protected $password

$username protected_oe property

protected $username