Constants

ROW_AS_ARRAY

ROW_AS_ARRAY

Data set result constants

ROW_AS_OBJECT

ROW_AS_OBJECT

ROW_AS_RESULT

ROW_AS_RESULT

Properties

$db

$db : array

Database connection(s)

Type

array

$table

$table : string

Table name

Type

string

$prefix

$prefix : string

Table prefix

Type

string

$primaryKeys

$primaryKeys : array

Primary keys

Type

array

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

hasDb()

hasDb() : boolean

Check is the class has a DB adapter

Returns

boolean

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

hasSql()

hasSql() : boolean

Determine if there is a Sql object

Returns

boolean

getSql()

getSql() : \Pop\Db\Sql

Get Sql object

Returns

\Pop\Db\Sql

sql()

sql() : \Pop\Db\Sql

Get Sql object (alias)

Returns

\Pop\Db\Sql

findById()

findById(mixed  $id, string  $resultsAs = \Pop\Db\Record::ROW_AS_OBJECT) : \Pop\Db\Record\Result

Find by ID static method

Parameters

mixed $id
string $resultsAs

Returns

\Pop\Db\Record\Result

findBy()

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

Find by static method

Parameters

array $columns
array $options
string $resultsAs

Returns

\Pop\Db\Record\Result

findAll()

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

Find all static method

Parameters

array $options
string $resultsAs

Returns

\Pop\Db\Record\Result

execute()

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

Static method to execute a custom prepared SQL statement.

Parameters

mixed $sql
mixed $params
string $resultsAs

Returns

\Pop\Db\Record\Result

query()

query(mixed  $sql, string  $resultsAs = \Pop\Db\Record::ROW_AS_OBJECT) : \Pop\Db\Record\Result

Static method to execute a custom SQL query.

Parameters

mixed $sql
string $resultsAs

Returns

\Pop\Db\Record\Result

getTotal()

getTotal(array  $columns = null, string  $resultsAs = \Pop\Db\Record::ROW_AS_OBJECT) : integer

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

Parameters

array $columns
string $resultsAs

Returns

integer

getTableInfo()

getTableInfo() : array

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

Returns

array

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

getResult()

getResult() : \Pop\Db\Record\Result

Get the record result object

Returns

\Pop\Db\Record\Result

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

getPrimaryKeys()

getPrimaryKeys() : array

Get the primary keys

Returns

array

getColumns()

getColumns() : array

Get the columns

Returns

array

getRows()

getRows() : array

Get the rows

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 = \Pop\Db\Record::ROW_AS_OBJECT) : void

Save the result

Parameters

array $columns
string $resultsAs

delete()

delete(array  $columns = null) : void

Delete the result records or rows of result 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