Constants

AS_ARRAY

AS_ARRAY

Constants to set individual row data type

AS_OBJECT

AS_OBJECT

AS_RECORD

AS_RECORD

Properties

$table

$table : string

Table name

Type

string

$prefix

$prefix : string

Table prefix

Type

string

$primaryKeys

$primaryKeys : array

Primary keys

Type

array

$isNew

$isNew : boolean

Is new record flag

Type

boolean

$oneToOne

$oneToOne : array

1:1 associations

Type

array

$hasOne

$hasOne : array

1:1 association objects

Type

array

$oneToMany

$oneToMany : array

1:Many associations

Type

array

$hasMany

$hasMany : array

1:many association objects

Type

array

$belongsTo

$belongsTo : array

1:1 belongs to associations

Type

array

$doesBelong

$doesBelong : array

1:1 belongs to association object

Type

array

$relationships

$relationships : array

Eager relationships

Type

array

$with

$with : array

Eager with

Type

array

$withOptions

$withOptions : array

Eager with options

Type

array

Methods

setTable()

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

Set the table

Parameters

string $table

Returns

\Pop\Db\Record\AbstractRecord

setTableFromClassName()

setTableFromClassName(string  $class) : mixed

Set the table from a class name

Parameters

string $class

Returns

mixed

setPrefix()

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

Set the table prefix

Parameters

string $prefix

Returns

\Pop\Db\Record\AbstractRecord

setPrimaryKeys()

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

Set the primary keys

Parameters

array $keys

Returns

\Pop\Db\Record\AbstractRecord

hasRelationships()

hasRelationships(integer  $id) : boolean

Has eager relationships

Parameters

integer $id

Returns

boolean

getRelationships()

getRelationships(integer  $id = null) : array

Get eager relationships

Parameters

integer $id

Returns

array

addWith()

addWith(string  $name, array  $options = null) : \Pop\Db\Record\AbstractRecord

Set eager with

Parameters

string $name
array $options

Returns

\Pop\Db\Record\AbstractRecord

getWith()

getWith() : static

With a 1:many relationship (eager-loading)

Returns

static

getTable()

getTable() : string

Get the table

Returns

string

getFullTable()

getFullTable() : string

Get the full table name (prefix + table)

Returns

string

getPrefix()

getPrefix() : string

Get the table prefix

Returns

string

getPrimaryKeys()

getPrimaryKeys() : array

Get the primary keys

Returns

array

getRowGateway()

getRowGateway() : \Pop\Db\Gateway\Row

Get the row gateway

Returns

\Pop\Db\Gateway\Row

getTableGateway()

getTableGateway() : \Pop\Db\Gateway\Table

Get the table gateway

Returns

\Pop\Db\Gateway\Table

toArray()

toArray() : array

Get column values as array

Returns

array

toArrayObject()

toArrayObject() : \ArrayObject

Get column values as array object

Returns

\ArrayObject

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

setColumns()

setColumns(mixed  $columns = null) : \Pop\Db\Record\AbstractRecord

Set all the table column values at once

Parameters

mixed $columns

Throws

\Pop\Db\Record\Exception

Returns

\Pop\Db\Record\AbstractRecord

setRows()

setRows(array  $rows = null, string  $resultAs = \Pop\Db\Record\AbstractRecord::AS_RECORD) : \Pop\Db\Record\AbstractRecord

Set all the table rows at once

Parameters

array $rows
string $resultAs

Returns

\Pop\Db\Record\AbstractRecord

processRows()

processRows(array  $rows, string  $resultAs = \Pop\Db\Record\AbstractRecord::AS_RECORD) : array

Process table rows

Parameters

array $rows
string $resultAs

Returns

array

processRow()

processRow(array  $row, string  $resultAs = \Pop\Db\Record\AbstractRecord::AS_RECORD) : mixed

Process a table row

Parameters

array $row
string $resultAs

Returns

mixed

__set()

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

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

Parameters

string $name
mixed $value

__get()

__get(string  $name) : mixed

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

Parameters

string $name

Returns

mixed

__isset()

__isset(string  $name) : boolean

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

Parameters

string $name

Returns

boolean

__unset()

__unset(string  $name) : void

Magic method to unset $this->rowGateway[$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

offsetUnset()

offsetUnset(mixed  $offset) : void

ArrayAccess offsetUnset

Parameters

mixed $offset

__construct()

__construct() 

Constructor

Instantiate the database record object

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

Throws

\Pop\Db\Exception

hasDb()

hasDb() : boolean

Check for a DB adapter

Returns

boolean

setDb()

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

Set DB adapter

Parameters

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

getSql()

getSql() : \Pop\Db\Sql

Get SQL builder

Returns

\Pop\Db\Sql

sql()

sql() : \Pop\Db\Sql

Get SQL builder (alias)

Returns

\Pop\Db\Sql

table()

table() : string

Get table name

Returns

string

findById()

findById(mixed  $id) : static|\Pop\Db\Record\Collection

Find by ID static method

Parameters

mixed $id

Returns

static|\Pop\Db\Record\Collection

findOne()

findOne(array  $columns = null, array  $options = null) : static

Find one static method

Parameters

array $columns
array $options

Returns

static

findOneOrCreate()

findOneOrCreate(array  $columns = null, array  $options = null) : static

Find one or create static method

Parameters

array $columns
array $options

Returns

static

findLatest()

findLatest(string  $by = null, array  $columns = null, array  $options = null) : static

Find latest static method

Parameters

string $by
array $columns
array $options

Returns

static

findBy()

findBy(array  $columns = null, array  $options = null, string  $resultAs = \Pop\Db\Record::AS_RECORD) : \Pop\Db\Record\Collection

Find by static method

Parameters

array $columns
array $options
string $resultAs

Returns

\Pop\Db\Record\Collection

findByOrCreate()

findByOrCreate(array  $columns = null, array  $options = null, string  $resultAs = \Pop\Db\Record::AS_RECORD) : \Pop\Db\Record\Collection

Find by or create static method

Parameters

array $columns
array $options
string $resultAs

Returns

\Pop\Db\Record\Collection

findAll()

findAll(array  $options = null, string  $resultAs = \Pop\Db\Record::AS_RECORD) : \Pop\Db\Record\Collection

Find all static method

Parameters

array $options
string $resultAs

Returns

\Pop\Db\Record\Collection

execute()

execute(mixed  $sql, array  $params, string  $resultAs = \Pop\Db\Record::AS_RECORD) : \Pop\Db\Record\Collection

Static method to execute a custom prepared SQL statement.

Parameters

mixed $sql
array $params
string $resultAs

Returns

\Pop\Db\Record\Collection

query()

query(mixed  $sql, string  $resultAs = \Pop\Db\Record::AS_RECORD) : \Pop\Db\Record\Collection

Static method to execute a custom SQL query.

Parameters

mixed $sql
string $resultAs

Returns

\Pop\Db\Record\Collection

with()

with(mixed  $name, array  $options = null) : mixed

With a 1:many relationship (eager-loading)

Parameters

mixed $name
array $options

Returns

mixed

getTotal()

getTotal(array  $columns = null) : integer

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

Parameters

array $columns

Returns

integer

getTableInfo()

getTableInfo() : array

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

Returns

array

getById()

getById(mixed  $id) : static|\Pop\Db\Record\Collection

Get by ID method

Parameters

mixed $id

Returns

static|\Pop\Db\Record\Collection

getOneBy()

getOneBy(array  $columns = null, array  $options = null) : static

Get one method

Parameters

array $columns
array $options

Returns

static

getBy()

getBy(array  $columns = null, array  $options = null, string  $resultAs = \Pop\Db\Record::AS_RECORD) : \Pop\Db\Record\Collection

Get by method

Parameters

array $columns
array $options
string $resultAs

Returns

\Pop\Db\Record\Collection

getAll()

getAll(array  $options = null, string  $resultAs = \Pop\Db\Record::AS_RECORD) : \Pop\Db\Record\Collection

Get all method

Parameters

array $options
string $resultAs

Returns

\Pop\Db\Record\Collection

increment()

increment(string  $column, integer  $amount = 1) : void

Increment the record column and save

Parameters

string $column
integer $amount

decrement()

decrement(string  $column, integer  $amount = 1) : void

Decrement the record column and save

Parameters

string $column
integer $amount

replicate()

replicate(array  $replace = array()) : static

Replicate the record

Parameters

array $replace

Returns

static

isDirty()

isDirty() : boolean

Check if row is dirty

Returns

boolean

getDirty()

getDirty() : array

Get row's dirty columns

Returns

array

save()

save(array  $columns = null) : void

Save the record

Parameters

array $columns

delete()

delete(array  $columns = null) : void

Delete the record

Parameters

array $columns

hasOne()

hasOne(string  $class, mixed  $foreignKey = null) : mixed

Add a 1:1 relationship

Parameters

string $class
mixed $foreignKey

Returns

mixed

hasMany()

hasMany(string  $class, mixed  $foreignKey = null, array  $options = null, boolean  $eager = false) : mixed

Add a 1:many relationship

Parameters

string $class
mixed $foreignKey
array $options
boolean $eager

Returns

mixed

belongsTo()

belongsTo(string  $class, mixed  $foreignKey = null) : mixed

Add a 1:1 belongs to relationship

Parameters

string $class
mixed $foreignKey

Returns

mixed

getOne()

getOne(string  $class) : mixed

Get a 1:1 relationship

Parameters

string $class

Returns

mixed

getMany()

getMany(string  $class, array  $options = null) : mixed

Get a 1:many relationship

Parameters

string $class
array $options

Returns

mixed

getManyEager()

getManyEager(string  $class, array  $options = null) : array

Get a 1:many eager relationship

Parameters

string $class
array $options

Returns

array

getBelong()

getBelong(string  $class) : mixed

Get a 1:1 belongs to relationship

Parameters

string $class

Returns

mixed

__callStatic()

__callStatic(string  $name, array  $arguments) : mixed

Call static method

Parameters

string $name
array $arguments

Returns

mixed