Properties

$Fields

$Fields : string

Fields to be fetched and transformed.

Type

string — Fields substitution.

$TableName

$TableName : 

Table name.

Type

Methods

__construct()

__construct(string  $Fields = '*', string  $TableName = '') 

Constructor.

Parameters

string $Fields
  • fields of the model;
string $TableName
  • name of the table;

set_table_name()

set_table_name(string  $TableName = '') 

Method sets table name.

Parameters

string $TableName
  • Table name.

new_records_since()

new_records_since(\datetime  $Date) : array

Method returns all records created since $Date.

Parameters

\datetime $Date
  • Start of the period.

Returns

array —

List of records created since $Date.

records_count()

records_count() : \number

Method returns amount of records in table.

Returns

\number —

Amount of records.

get_simple_records()

get_simple_records(integer|boolean  $DomainId, integer  $From, integer  $Limit, array  $Where, array  $Order) : array

Method fetches records before transformation.

Parameters

integer|boolean $DomainId
  • Id of the doomain.
integer $From
  • Starting record.
integer $Limit
  • Fetch limit.
array $Where
  • Fetch condition.
array $Order
  • Sorting condition.

Returns

array —

of records.

last_records()

last_records(integer  $Count, array  $Where) : array

Method returns last $Count records.

Parameters

integer $Count
  • Amount of records to be returned.
array $Where
  • Filter conditions.

Returns

array —

List of the last $Count records.

fetch_records_by_ids()

fetch_records_by_ids(integer  $ids,   $DomainId) : array

Method fetches records bythe specified fields.

Parameters

integer $ids

-ids of records to be fetched.

$DomainId

Returns

array —
  • list of records.

records_count_by_field()

records_count_by_field(string  $FieldName, array  $Where) : array

Method returns amount of records in table, grouped by the specified field.

Parameters

string $FieldName
  • Grouping field.
array $Where
  • Filtration conditions.

Returns

array —

Records with stat.

delete_filtered()

delete_filtered(mixed  $DomainId, array  $Where) 

Method deletes filtered records.

Parameters

mixed $DomainId
  • Domain id.
array $Where
  • Filtration conditions.

insert_basic_fields()

insert_basic_fields(array  $Record) : array

Method inserts simple record in the table.

Parameters

array $Record
  • Record to be inserted.

Returns

array —

Inserted record.

process_fetched_records()

process_fetched_records(array  $Records, array  $FieldCompiler, boolean  $HasCustomFields) : array

Method processes records.

Parameters

array $Records

- records to be processed.

array $FieldCompiler

- field compiler.

boolean $HasCustomFields

- Does model contains custom fields.

Returns

array —

Processed records.

delete_record()

delete_record(integer  $id,   $DomainId) : integer

Method deletes the specified record.

Parameters

integer $id
  • Id of the deleting record.
$DomainId

Returns

integer —

id of the deleted record.

update_basic_fields()

update_basic_fields(array  $Record, array  $Where) : array

Method updates records.

Parameters

array $Record
  • New values for fields.
array $Where
  • Condition.

Returns

array —

Updated fields.

increment_views()

increment_views(integer  $id) : \number

Method increments ammount of views.

Parameters

integer $id
  • Idof the record.

Returns

\number —

New amount ov views.

get_connection()

get_connection() : boolean|\PDOCrud

Method returns connection to the DB.

Returns

boolean|\PDOCrud —
  • PDO DB connection or false on error.