PHP Interface Airship\Engine\Contract\DBInterface

An interface for database interaction.
Show file Open project: paragonie/airship Interface Usage Examples

Public Methods

Method Description
cell ( string $statement, $params ) : mixed Variadic version of $this->single()
col ( string $statement, integer $offset, $params ) : mixed Variadic version of $this->column()
column ( string $statement, array $params = [], integer $offset ) : mixed Fetch a column
delete ( string $table, array $conditions ) Delete rows in a database table.
first ( string $statement, $params ) : mixed Variadic version of $this->column(), with an offset of 0
getDriver ( ) : string Which database driver are we operating on?
getPdo ( ) : PDO Return the PDO object directly
insert ( string $table, array $map ) Insert a new row to a table in a database.
row ( string $statement, $params ) Similar to $this->run() except it only returns a single row
run ( string $statement, $params ) : mixed Run a query, get a 2D array with all the results
single ( string $statement, array $params = [] ) : mixed Fetch a single result -- useful for SELECT COUNT() queries
update ( string $table, array $changes, array $conditions ) Update a row in a database table.

Method Details

cell() public method

Variadic version of $this->single()
public cell ( string $statement, $params ) : mixed
$statement string SQL query without user data
$params Parameters
return mixed

col() public method

Variadic version of $this->column()
public col ( string $statement, integer $offset, $params ) : mixed
$statement string SQL query without user data
$offset integer - How many columns from the left are we grabbing from each row?
$params Parameters
return mixed

column() public method

Fetch a column
public column ( string $statement, array $params = [], integer $offset ) : mixed
$statement string SQL query without user data
$params array Parameters
$offset integer - How many columns from the left are we grabbing from each row?
return mixed

delete() public method

Delete rows in a database table.
public delete ( string $table, array $conditions )
$table string - table name
$conditions array - WHERE clause

first() public method

Variadic version of $this->column(), with an offset of 0
public first ( string $statement, $params ) : mixed
$statement string SQL query without user data
$params Parameters
return mixed

getDriver() public method

Which database driver are we operating on?
public getDriver ( ) : string
return string

getPdo() public method

Return the PDO object directly
public getPdo ( ) : PDO
return PDO

insert() public method

Insert a new row to a table in a database.
public insert ( string $table, array $map )
$table string - table name
$map array - associative array of which values should be assigned to each field

row() public method

Similar to $this->run() except it only returns a single row
public row ( string $statement, $params )
$statement string SQL query without user data
$params Parameters

run() public method

Run a query, get a 2D array with all the results
public run ( string $statement, $params ) : mixed
$statement string SQL query without user data
$params Parameters
return mixed - If successful, a 2D array

single() public method

Fetch a single result -- useful for SELECT COUNT() queries
public single ( string $statement, array $params = [] ) : mixed
$statement string
$params array
return mixed

update() public method

Update a row in a database table.
public update ( string $table, array $changes, array $conditions )
$table string - table name
$changes array - associative array of which values should be assigned to each field
$conditions array - WHERE clause