AbstractModel Class

Aurora\Database\Model Namespace

Interfaces

  • I JsonSerializable

Properties

table

Table name

protected static $table = '': string

model

Model name

protected static $model = '': string

fields

Model fields

protected static $fields = []: array

update

Model fields for update

protected static $update = []: array

defaults

Default values

protected static $defaults = []: array

field_primary

Primary field name

protected static $field_primary = 'id': string

field_created

Created field name

protected static $field_created = 'created': string

field_updated

Updated field name

protected static $field_updated = 'modified': string

Constructor

__construct

Constructor

Parameters

  • Aurora\Database\Query\Query $query — Query object

Signature

public function __construct(Aurora\Database\Query\Query $query)

Methods

__construct

Constructor

Parameters

  • Aurora\Database\Query\Query $query — Query object

Signature

public function __construct(Aurora\Database\Query\Query $query)

query

Query the model table

Return Value

  • \Query

Signature

public function query(): Aurora\Database\Query\Query

all

Get all rows from the model table

Parameters

  • mixed $columns — Which columns to get

Return Value

  • mixed

Signature

public function all(mixed $columns = '*')

first

Get a single row from the model table

Parameters

  • mixed $columns — Which columns to get

Return Value

  • mixed

Signature

public function first(mixed $columns = '*')

get

Get a row by its primary ID

Parameters

  • mixed $id — Entity ID
  • mixed $columns — Which columns to get

Return Value

  • mixed

Signature

public function get(mixed $id, mixed $columns = '*')

getBy

Get a row by an specific field

Parameters

  • mixed $field — Field name
  • mixed $value — Field value
  • mixed $columns — Which columns to get

Return Value

  • mixed

Signature

public function getBy(mixed $field, mixed $value, mixed $columns = '*')

count

Get the number of rows

Parameters

  • mixed $column — Which column to use

Return Value

  • int

Signature

public function count(mixed $column): int

min

Get minimum value

Parameters

  • mixed $column — Which column to use

Return Value

  • mixed

Signature

public function min(mixed $column)

max

Get maximum value

Parameters

  • mixed $column — Which column to use

Return Value

  • mixed

Signature

public function max(mixed $column)

avg

Get average value

Parameters

  • mixed $column — Which column to use

Return Value

  • mixed

Signature

public function avg(mixed $column)

sum

Get sum value

Parameters

  • mixed $column — Which column to use

Return Value

  • mixed

Signature

public function sum(mixed $column)

where

Add where clause

Parameters

  • mixed $column — Column
  • mixed $value — Column value
  • string $operator — Comparison operator
  • string $boolean — Boolean operator

Return Value

  • \Query

Signature

public function where(mixed $column, mixed $value, string $operator = '=', string $boolean = 'AND'): Aurora\Database\Query\Query

whereColumn

Add where clause for two columns

Parameters

  • mixed $column — Column
  • mixed $value — Column value
  • string $operator — Comparison operator
  • string $boolean — Boolean operator

Return Value

  • \Query

Signature

public function whereColumn(mixed $column, mixed $value, string $operator = '=', string $boolean = 'AND'): Aurora\Database\Query\Query

chunk

Get chunked rows

Parameters

  • Closure $callback — Callback function
  • int $size — Chunk size

Return Value

  • mixed

Signature

public function chunk(Closure $callback, int $size)

delete

Delete entity

Return Value

  • void

Signature

public function delete(): void

save

Save entity

Return Value

  • void

Signature

public function save(): void

refresh

Reload fields from database

Return Value

  • void

Signature

public function refresh(): void

getTable

Get table name

Return Value

  • string

Signature

public function getTable()

getFields

Get field names

Parameters

  • mixed $update — Return fields for update only

Return Value

  • array

Signature

public function getFields(mixed $update)

saveProc

Save procedure

Parameters

  • Aurora\Database\Query\Query $query — Current Query object

Return Value

  • void

Signature

protected function saveProc(Aurora\Database\Query\Query $query): void

updateProc

Update procedure

Parameters

  • Aurora\Database\Query\Query $query — Current Query object

Return Value

  • void

Signature

protected function updateProc(Aurora\Database\Query\Query $query): void

deleteProc

Delete procedure

Parameters

  • Aurora\Database\Query\Query $query — Current Query object

Return Value

  • void

Signature

protected function deleteProc(Aurora\Database\Query\Query $query): void

refreshProc

Refresh procedure

Parameters

  • Aurora\Database\Query\Query $query — Current Query object

Return Value

  • void

Signature

protected function refreshProc(Aurora\Database\Query\Query $query): void

beforeSave

Before save callback

Return Value

  • bool

Signature

protected function beforeSave(): bool

afterSave

After save callback

Return Value

  • void

Signature

protected function afterSave(): void

beforeDelete

Before delete callback

Return Value

  • bool

Signature

protected function beforeDelete(): bool

afterDelete

After delete callback

Return Value

  • void

Signature

protected function afterDelete(): void

beforeRefresh

Before refresh callback

Return Value

  • bool

Signature

protected function beforeRefresh(): bool

afterRefresh

After refresh callback

Return Value

  • void

Signature

protected function afterRefresh(): void

jsonSerialize

jsonSerialize implementation placeholder

Return Value

  • mixed

Signature

public function jsonSerialize()

__callStatic

Resolve static method calls

Parameters

  • string $name — Static method name
  • array $arguments — Method arguments

Return Value

  • mixed

Signature

public function __callStatic(string $name, array $arguments)

Go to top