Properties

$table

$table : string

Type

string — This is the database table for this model.

$save_data_copy

$save_data_copy : integer

Type

integer — This is private var to use on this class.

$primary_key

$primary_key : string

Type

string — This is the name of the primary key field for our model.

Methods

__construct()

__construct() 

Constructor

get_one()

get_one(integer  $id) : array

Fetch a single record based on the primary key. Return an array

Parameters

integer $id

ID for primary key

Returns

array

get_all()

get_all() : array

Fetch all the records in the table.

Returns

array

get_select()

get_select(string  $text_field, array  $filter = NULL) : array

Retrieve and generate a form_dropdown friendly array

Parameters

string $text_field

Column field used to get text data

array $filter

Used to apply a filter

Returns

array

save()

save(integer  $id = null, array  $data) : false|integer

Manage $data array to insert or update if $id exists

Parameters

integer $id

ID for primary key

array $data

Array

Returns

false|integer

_before_save()

_before_save(integer  $id, array  $data) 

This callback runs before save of the crud.

The callback takes as a 1st parameter the primary key value and as 2nd the post array. With this opportunity you can add or unset some post variables.

Parameters

integer $id

Primary key

array $data

Array

insert()

insert(array  $data) : integer

Insert a new row into the table. $data should be an associative array of data to be inserted. Returns newly created ID.

Parameters

array $data

Array

Returns

integer

update()

update(integer  $id, array  $data) : false|integer

Updated a record based on the primary value.

Parameters

integer $id

Primary key

array $data

Array

Returns

false|integer

affected_rows()

affected_rows() 

Return number of affected rows on last query.

delete()

delete(integer  $id) : integer

Delete a row from the table by the primary value

Parameters

integer $id

Primary key

Returns

integer

_callback_table()

_callback_table() 

This callback runs on the read_table method.

With this opportunity you can implement other database instructions like join.

read_table()

read_table(array  $items, array  $or_like = array(), array  $order = array(), integer  $Pagesize, integer  $Offset, true|false  $count = FALSE, null|array  $filter = NULL) 

Return data for table of the crud.

Recive some params to make database query & return data

Parameters

array $items

Contain columns names to get from database

array $or_like

-

array $order

Specifies data order, use a simple array using key for column & value for direction

integer $Pagesize

Specifies the maximum number of rows to return

integer $Offset

Specifies the offset of the first row to return

true|false $count
null|array $filter

-

get_business_partnerlist()

get_business_partnerlist() : array

Retrieve and generate a form_dropdown friendly array

Returns

array

_get_virtuals()

_get_virtuals(integer  $id, array  $data) 

Helper for get_one method to concat extra information for return

Parameters

integer $id

ID for primary key

array $data

Array

_before_insert()

_before_insert(array  $data) 

This callback runs before the insert of the crud.

The callback takes as a 1st parameter the post array. With this opportunity you can add or unset some post variables.

Parameters

array $data

Array

_before_update()

_before_update(integer  $id, array  $data) 

This callback runs before the update of the crud.

The callback takes as a 1st parameter the primary key value and as 2nd the post array. With this opportunity you can add or unset some post variables.

Parameters

integer $id

Primary key

array $data

Array

_after_insert()

_after_insert(integer  $id) 

This callback runs after the insert of the crud.

The callback takes as a 1st parameter the primary key value. With this opportunity you can do other actions after insert.

Parameters

integer $id

Primary key

_after_update()

_after_update(integer  $id) 

This callback runs after the update of the crud.

The callback takes as a 1st parameter the primary key value. With this opportunity you can do other actions after update.

Parameters

integer $id

Primary key

_after_save()

_after_save(integer  $id) 

This callback runs after the insert/update of the crud.

The callback takes as a 1st parameter the primary key value. With this opportunity you can do other actions after insert/update.

Parameters

integer $id

Primary key

_after_delete()

_after_delete() 

This callback runs after the delete of the crud.

With this opportunity you can do other actions after delete.

_before_delete()

_before_delete(integer  $id) 

This callback runs before the delete of the crud.

The callback takes as a 1st parameter the primary key value. With this opportunity you can do other actions before delete.

Parameters

integer $id

Primary key