PHP Class Psecio\Gatekeeper\DataSource\Mysql

Inheritance: extends Psecio\Gatekeeper\DataSource
Exibir arquivo Open project: psecio/gatekeeper

Protected Properties

Property Type Description
$db PDO PDO instance

Public Methods

Method Description
__construct ( array $config, PDO $pdo = null ) Create our PDO connection, then call parent
buildPdo ( array $config ) : PDO Build the PDO instance
count ( Modler\Model $model, array $where = [] ) : array Find count of entities by where conditions.
create ( Modler\Model $model ) : boolean Create the record based on the data from the model
delete ( Modler\Model $model ) : boolean Delete a record represented by the model
execute ( string $sql, array $data ) : boolean Execute the request (not a fetch)
fetch ( string $sql, array $data, boolean $single = false ) : array | boolean Fetch the data matching the results of the SQL operation
find ( Modler\Model $model, array $where = [], boolean $multiple = false ) : array Find records matching the "where" data given All "where" options are appended via "and"
getDb ( ) : PDO Get the set PDO instance
getLastError ( ) : string Return the last error for the data source
save ( Modler\Model $model ) : boolean Save the model and its data (either create or update)
setDb ( PDO $db ) Set the PDO instance
setup ( array $data ) : array "Set up" the needed values for the database requests (for binding to queries)
update ( Modler\Model $model ) : boolean Update a record

Method Details

__construct() public method

Create our PDO connection, then call parent
public __construct ( array $config, PDO $pdo = null )
$config array Configuration options
$pdo PDO PDO instance

buildPdo() public method

Build the PDO instance
public buildPdo ( array $config ) : PDO
$config array Configuration options
return PDO instance

count() public method

All where conditions applied with AND
public count ( Modler\Model $model, array $where = [] ) : array
$model Modler\Model Model instance
$where array Data to use in "where" statement
return array Fetched data

create() public method

Create the record based on the data from the model
public create ( Modler\Model $model ) : boolean
$model Modler\Model Model instance
return boolean Success/fail of create action

delete() public method

Delete a record represented by the model
public delete ( Modler\Model $model ) : boolean
$model Modler\Model Model instance
return boolean Success/failure of deletion

execute() public method

Execute the request (not a fetch)
public execute ( string $sql, array $data ) : boolean
$sql string SQL statement to execute
$data array Data to use in execution
return boolean Success/fail of the operation

fetch() public method

Fetch the data matching the results of the SQL operation
public fetch ( string $sql, array $data, boolean $single = false ) : array | boolean
$sql string SQL statement
$data array Data to use in fetch operation
$single boolean Only fetch a single record
return array | boolean Fetched data or boolean false on error

find() public method

Find records matching the "where" data given All "where" options are appended via "and"
public find ( Modler\Model $model, array $where = [], boolean $multiple = false ) : array
$model Modler\Model Model instance
$where array Data to use in "where" statement
$multiple boolean Force return of single/multiple
return array Fetched data

getDb() public method

Get the set PDO instance
public getDb ( ) : PDO
return PDO instance

getLastError() public method

Return the last error for the data source
public getLastError ( ) : string
return string Error string

save() public method

Save the model and its data (either create or update)
public save ( Modler\Model $model ) : boolean
$model Modler\Model Model instance
return boolean Success/fail of save action

setDb() public method

Set the PDO instance
public setDb ( PDO $db )
$db PDO PDO instance

setup() public method

"Set up" the needed values for the database requests (for binding to queries)
public setup ( array $data ) : array
$data array Data to "set up"
return array Set containing the columns and bind values

update() public method

Update a record
public update ( Modler\Model $model ) : boolean
$model Modler\Model Model instance
return boolean Success/fail of operation

Property Details

$db protected_oe property

PDO instance
protected PDO $db
return PDO