Properties

$table

$table : string

Type

string — This is the database table for this model.

$primary_key

$primary_key : string

Type

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

$doc_id

$doc_id : integer

Type

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

$client_id

$client_id : integer

Type

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

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_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

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

_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

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

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_by_client_id()

get_by_client_id(integer  $client_id) : array

Fetch all the records in the table filtered by client_id

Parameters

integer $client_id

Client ID

Returns

array

get_by_repo_doc_id()

get_by_repo_doc_id(integer  $repo_doc_id) : integer

Fetch a count of rows based on $repo_doc_id filter

Parameters

integer $repo_doc_id

Document ID

Returns

integer

get_esb_by_repo_doc_id()

get_esb_by_repo_doc_id(integer  $repo_doc_id) : array

Fetch all the external ID of clients that have an assigned specified doc

Parameters

integer $repo_doc_id

Document ID

Returns

array

get_by_client_doc()

get_by_client_doc(integer  $client_id, integer  $doc_id) : array

Fetch a single record. Returns an array

Parameters

integer $client_id

Client ID

integer $doc_id

Document ID

Returns

array

set_client_doc()

set_client_doc(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

unset_by_client_doc()

unset_by_client_doc(integer  $client_id, integer  $doc_id) : true

Delete a row from the table by Client ID & Document ID

Parameters

integer $client_id

Client ID

integer $doc_id

Document ID

Returns

true

get_ids_by_client_id()

get_ids_by_client_id(integer  $client_id) : array

Fetch all the records in the table filtered by client_id & return an array containing repo_doc_id field of every row

Parameters

integer $client_id

Client ID

Returns

array

get_tree()

get_tree(integer  $client_id) : array

Make a multidimensional array with information about docs for a specified client ID.

Parameters

integer $client_id

Client ID

Returns

array

set_doc_id()

set_doc_id(integer  $doc_id) 

Set private var category_id.

Parameters

integer $doc_id

Document ID

set_client_id()

set_client_id(integer  $client_id) 

Set private var category_id.

Parameters

integer $client_id

Client ID

_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_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

_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

_callback_table()

_callback_table() 

This callback runs on the read_table method.

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

save_model_data()

save_model_data(array  $data) 

Check if private vars repo_doc_id & client_id are setter to concat on data array.

Parameters

array $data

Post Array