Constants

ROW_AS_ARRAY

ROW_AS_ARRAY

Data set result constants

ROW_AS_ARRAYOBJECT

ROW_AS_ARRAYOBJECT

ROW_AS_RECORD

ROW_AS_RECORD

Properties

$db

$db : array

Database connection(s)

Type

array

$table

$table : string

Table name

Type

string

$prefix

$prefix : string

Table prefix

Type

string

$rows

$rows : array

Result rows (an array of arrays)

Type

array

$columns

$columns : string

Columns of the first result row

Type

string

$primaryKeys

$primaryKeys : array

Primary keys

Type

array

$isNew

$isNew : boolean

Is new record flag

Type

boolean

Methods

__construct()

__construct() : \Pop\Db\Record

Constructor

Instantiate the database record object.

Optional parameters are an array of values, db adapter, or a table name

Throws

\Pop\Db\Exception

Returns

\Pop\Db\Record

setDb()

setDb(\Pop\Db\Adapter\AbstractAdapter  $db, string  $prefix = null, boolean  $isDefault = false) : void

Set DB connection

Parameters

\Pop\Db\Adapter\AbstractAdapter $db
string $prefix
boolean $isDefault

hasDb()

hasDb() : boolean

Check is the class has a DB adapter

Returns

boolean

sql()

sql() : \Pop\Db\Sql

Get the SQL object

Throws

\Pop\Db\Exception

Returns

\Pop\Db\Sql

getSql()

getSql() : \Pop\Db\Sql

Get the SQL object

Returns

\Pop\Db\Sql

findById()

findById(mixed  $id, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Find by ID static method

Parameters

mixed $id
string $resultsAs

Returns

\Pop\Db\Record

findBy()

findBy(array  $columns = null, array  $options = null, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Find by static method

Parameters

array $columns
array $options
string $resultsAs

Returns

\Pop\Db\Record

findAll()

findAll(array  $options = null, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Find all static method

Parameters

array $options
string $resultsAs

Returns

\Pop\Db\Record

execute()

execute(mixed  $sql, mixed  $params, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Static method to execute a custom prepared SQL statement.

Parameters

mixed $sql
mixed $params
string $resultsAs

Returns

\Pop\Db\Record

query()

query(mixed  $sql, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Static method to execute a custom SQL query.

Parameters

mixed $sql
string $resultsAs

Returns

\Pop\Db\Record

getTotal()

getTotal(array  $columns = null, string  $resultsAs = 'ROW_AS_RECORD') : integer

Static method to get the total count of a set from the DB table

Parameters

array $columns
string $resultsAs

Returns

integer

findRecordById()

findRecordById(mixed  $id, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Find record by ID method

Parameters

mixed $id
string $resultsAs

Returns

\Pop\Db\Record

findRecordsBy()

findRecordsBy(array  $columns = null, array  $options = null, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Find records by method

Parameters

array $columns
array $options
string $resultsAs

Returns

\Pop\Db\Record

findAllRecords()

findAllRecords(array  $options = null, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Find all records method

Parameters

array $options
string $resultsAs

Returns

\Pop\Db\Record

executeStatement()

executeStatement(mixed  $sql, mixed  $params, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Method to execute a custom prepared SQL statement.

Parameters

mixed $sql
mixed $params
string $resultsAs

Returns

\Pop\Db\Record

executeQuery()

executeQuery(mixed  $sql, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Method to execute a custom SQL query.

Parameters

mixed $sql
string $resultsAs

Returns

\Pop\Db\Record

getTotalRecords()

getTotalRecords(array  $columns = null, string  $resultsAs = 'ROW_AS_RECORD') : integer

Method to get the total count of a set from the DB table

Parameters

array $columns
string $resultsAs

Returns

integer

setColumns()

setColumns(mixed  $columns = null, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Set all the table column values at once.

Parameters

mixed $columns
string $resultsAs

Throws

\Pop\Db\Exception

Returns

\Pop\Db\Record

setRows()

setRows(array  $rows = null, string  $resultsAs = 'ROW_AS_RECORD') : \Pop\Db\Record

Set all the table rows at once

Parameters

array $rows
string $resultsAs

Returns

\Pop\Db\Record

setPrefix()

setPrefix(string  $prefix) : \Pop\Db\Record

Set the table prefix

Parameters

string $prefix

Returns

\Pop\Db\Record

setTable()

setTable(string  $table) : \Pop\Db\Record

Set the table

Parameters

string $table

Returns

\Pop\Db\Record

setTableFromClassName()

setTableFromClassName(string  $class) : \Pop\Db\Record

Set the table from a class name

Parameters

string $class

Returns

\Pop\Db\Record

setPrimaryKeys()

setPrimaryKeys(array  $keys) : \Pop\Db\Record

Set the primary keys

Parameters

array $keys

Returns

\Pop\Db\Record

getPrefix()

getPrefix() : string

Get the table prefix

Returns

string

getTable()

getTable() : string

Get the table

Returns

string

getFullTable()

getFullTable() : string

Get the full table name (prefix + table)

Returns

string

getTableInfo()

getTableInfo() : array

Get table info and return as an array.

Returns

array

getPrimaryKeys()

getPrimaryKeys() : array

Get the primary keys

Returns

array

getColumns()

getColumns() : array

Get the columns

Returns

array

getColumnsAsObject()

getColumnsAsObject() : \ArrayObject

Get the columns as a single array object

Returns

\ArrayObject

toArray()

toArray() : array

Alias for getColumns

Returns

array

toArrayObject()

toArrayObject() : \ArrayObject

Alias to getColumnsAsObject

Returns

\ArrayObject

getRows()

getRows() : array

Get the rows

Returns

array

getRowObjects()

getRowObjects() : array

Get the rows - left in for BC

Returns

array

rows()

rows() : array

Get the rows (alias method)

Returns

array

count()

count() : integer

Get the count of rows returned in the result

Returns

integer

hasRows()

hasRows() : boolean

Determine if the result has rows

Returns

boolean

save()

save(array  $columns = null, string  $resultsAs = 'ROW_AS_RECORD') : void

Save the record

Parameters

array $columns
string $resultsAs

delete()

delete(array  $columns = null) : void

Delete the record or rows of records

Parameters

array $columns

__set()

__set(string  $name, mixed  $value) : void

Magic method to set the property to the value of $this->columns[$name].

Parameters

string $name
mixed $value

__get()

__get(string  $name) : mixed

Magic method to return the value of $this->columns[$name].

Parameters

string $name

Returns

mixed

__isset()

__isset(string  $name) : boolean

Magic method to return the isset value of $this->columns[$name].

Parameters

string $name

Returns

boolean

__unset()

__unset(string  $name) : void

Magic method to unset $this->columns[$name].

Parameters

string $name

offsetExists()

offsetExists(mixed  $offset) : boolean

ArrayAccess offsetExists

Parameters

mixed $offset

Returns

boolean

offsetGet()

offsetGet(mixed  $offset) : mixed

ArrayAccess offsetGet

Parameters

mixed $offset

Returns

mixed

offsetSet()

offsetSet(mixed  $offset, mixed  $value) : void

ArrayAccess offsetSet

Parameters

mixed $offset
mixed $value

Throws

\Pop\Db\Exception

offsetUnset()

offsetUnset(mixed  $offset) : void

ArrayAccess offsetUnset

Parameters

mixed $offset

Throws

\Pop\Db\Exception

getOperator()

getOperator(string  $column) : array

Method to get the operator from the column name

Parameters

string $column

Returns

array

parseColumns()

parseColumns(array  $columns, string  $placeholder) : array

Method to parse the columns to create $where and $param arrays

Parameters

array $columns
string $placeholder

Returns

array

camelCaseToUnderscore()

camelCaseToUnderscore(string  $string) : string

Method to convert a camelCase string to an under_score string

Parameters

string $string

Returns

string