PHP Class Pheasant\Database\Mysqli\Table

Show file Open project: lox/pheasant

Public Methods

Method Description
__construct ( $name, $connection ) Constructor
__toString ( ) Return the string name of the table
columns ( ) : array Returns all the database columns in SHOW COLUMN format
create ( $columns, $options = 'charset=utf8 engine=innodb' ) Creates the table, fails if the table exists
createIfNotExists ( $columns, $options = 'charset=utf8 engine=innodb' ) Creates the table if it doesn't exist
delete ( $criteria = NULL ) Deletes rows in the table
drop ( ) Drops the table
dropIfExists ( ) Drops the table if it exists
exists ( ) Determines if the table exists (name only, column definition not checked)
insert ( $data ) Inserts a row into the table
name ( ) Returns the name of the table as a TableName
query ( $criteria = null ) Builds a Query object for the table
replace ( $data ) Inserts a row, or replaces it entirely if a row with the primary key exists
truncate ( ) Truncates the table
update ( $data, Criteria $where, $limit = false ) Updates a row into the table
upsert ( $data ) Tries to update a record, or inserts if it doesn't exist. Worth noting that affectedRows will be 2 on an update, 1 on an insert.
where ( $where, $params = [] ) Builds a TableCriteria object for the table

Private Methods

Method Description
_buildSet ( $data ) Builds a series of X=?, Y=?, Z=?

Method Details

__construct() public method

Constructor
public __construct ( $name, $connection )
$name TableName

__toString() public method

Return the string name of the table
public __toString ( )

columns() public method

Returns all the database columns in SHOW COLUMN format
public columns ( ) : array
return array

create() public method

Creates the table, fails if the table exists
public create ( $columns, $options = 'charset=utf8 engine=innodb' )
$columns a map defining columns to Type objects

createIfNotExists() public method

Creates the table if it doesn't exist
public createIfNotExists ( $columns, $options = 'charset=utf8 engine=innodb' )

delete() public method

Deletes rows in the table
public delete ( $criteria = NULL )

drop() public method

Drops the table
public drop ( )

dropIfExists() public method

Drops the table if it exists
public dropIfExists ( )

exists() public method

Determines if the table exists (name only, column definition not checked)
public exists ( )

insert() public method

Inserts a row into the table
public insert ( $data )

name() public method

Returns the name of the table as a TableName
public name ( )

query() public method

Builds a Query object for the table
public query ( $criteria = null )

replace() public method

Inserts a row, or replaces it entirely if a row with the primary key exists
See also: http://dev.mysql.com/doc/refman/5.0/en/replace.html
public replace ( $data )

truncate() public method

Truncates the table
public truncate ( )

update() public method

Updates a row into the table
public update ( $data, Criteria $where, $limit = false )
$where Pheasant\Query\Criteria

upsert() public method

Tries to update a record, or inserts if it doesn't exist. Worth noting that affectedRows will be 2 on an update, 1 on an insert.
public upsert ( $data )

where() public method

Builds a TableCriteria object for the table
public where ( $where, $params = [] )