PHP Class OCA\Richdocuments\Db

Show file Open project: owncloud/richdocuments Class Usage Examples

Protected Properties

Property Type Description
$data
$insertStatement
$loadStatement
$tableName

Public Methods

Method Description
__call ( $name, $arguments )
__construct ( $data = [] )
deleteBy ( string $field, mixed $value ) Delete records matching the condition
getCollection ( ) : array Get all records from the table
getCollectionBy ( string $field, mixed $value ) : array Get array of matching records
getData ( ) : Array Get object data
getLastInsertId ( ) : mixed Get id of the recently inserted record
hasData ( ) : boolean Check if there are any data in current object
insert ( ) : mixed Insert current object data into database
load ( integer $value ) : Db Get single record by primary key
loadBy ( string $field, mixed $value ) : Db Get single record matching condition
setData ( array $data ) Set object data

Protected Methods

Method Description
buildInQuery ( string $field, Array $array ) : String Build placeholders for the query with variable input data
execute ( string $statement, mixed $args = null ) : mixed Execute a query on database

Method Details

__call() public method

public __call ( $name, $arguments )

__construct() public method

public __construct ( $data = [] )

buildInQuery() protected method

Build placeholders for the query with variable input data
protected buildInQuery ( string $field, Array $array ) : String
$field string field name
$array Array data
return String `field` IN (?, ?...) placeholders matching the number of elements in array

deleteBy() public method

Delete records matching the condition
public deleteBy ( string $field, mixed $value )
$field string for WHERE condition
$value mixed matching value(s)

execute() protected method

Execute a query on database
protected execute ( string $statement, mixed $args = null ) : mixed
$statement string query to be executed
$args mixed value(s) for the query. If omited the query will be run on the current object $data
return mixed (array/false)

getCollection() public method

Get all records from the table
public getCollection ( ) : array
return array

getCollectionBy() public method

Get array of matching records
public getCollectionBy ( string $field, mixed $value ) : array
$field string for WHERE condition
$value mixed matching value(s)
return array

getData() public method

Get object data
public getData ( ) : Array
return Array

getLastInsertId() public method

Get id of the recently inserted record
public getLastInsertId ( ) : mixed
return mixed

hasData() public method

Check if there are any data in current object
public hasData ( ) : boolean
return boolean

insert() public method

Insert current object data into database
public insert ( ) : mixed
return mixed

load() public method

Get single record by primary key
public load ( integer $value ) : Db
$value integer primary key value
return Db

loadBy() public method

Get single record matching condition
public loadBy ( string $field, mixed $value ) : Db
$field string for WHERE condition
$value mixed matching value(s)
return Db

setData() public method

Set object data
public setData ( array $data )
$data array

Property Details

$data protected property

protected $data

$insertStatement protected property

protected $insertStatement

$loadStatement protected property

protected $loadStatement

$tableName protected property

protected $tableName