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.

$parent_id

$parent_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_tree()

get_tree(integer  $client_id) : array

Make a multidimensional array with information about docs.

Parameters

integer $client_id

Client ID.

Returns

array

get_by_parent()

get_by_parent(integer  $client_id, integer|null  $parent_id = NULL) : array

Fetch all the records in the table filtered by Client ID & Parent ID

Parameters

integer $client_id

Client ID.

integer|null $parent_id

Parent ID

Returns

array

set_parent_id()

set_parent_id(integer|null  $parent_id) 

Set private var parent_id.

Parameters

integer|null $parent_id

Parent ID

set_client_id()

set_client_id(integer|null  $client_id) 

Set private var client_id.

Parameters

integer|null $client_id

Client ID

_delete()

_delete(string  $id, string  $back = '', string  $target = '', string  $ok = NULL, true|false  $wrap = TRUE) : mixed

Help delete method to return layout view for delete section of crud or to process submit for delete section.

Parameters

string $id

Primary key value

string $back

Segment url passed to base_url helper used to back when click on cancel button on delete section

string $target

Segment url passed to base_url helper used to go when click on submit button on delete section

string $ok

-

true|false $wrap

-

Returns

mixed

getinvoice()

getinvoice(integer  $client_id) : integer

Fetch a single record based on the Client ID. Return an primary key value

Parameters

integer $client_id

Client ID

Returns

integer

createinvoice()

createinvoice(integer  $client_id) : integer

Insert a new row into the table with isinvoice column setter to 1 or update if exist data for provided Client ID param.

Parameters

integer $client_id

Client ID

Returns

integer

deactivateinvoice()

deactivateinvoice(integer  $client_id) : integer

Set isinvoice to 0 if exist data for provided Client ID param

Parameters

integer $client_id

Client ID

Returns

integer

get_custom_one()

get_custom_one(integer  $id) : array

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

Parameters

integer $id

ID

Returns

array

getidbycategoryid()

getidbycategoryid(integer  $cat_ID) : array

Fetch a single record based on Category ID. Return an array

Parameters

integer $cat_ID

ID

Returns

array

setclientcategories()

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

Post data

Returns

integer

updateclientcategories()

updateclientcategories(integer  $cat_ID, integer  $client_id, array  $data) : integer

Updated a record based on the primary value.

Parameters

integer $cat_ID

ID

integer $client_id

Client ID

array $data

Post data

Returns

integer

deleteclientcategories()

deleteclientcategories(integer  $cat_ID, integer  $client_id) : integer

Delete a row from the table by the primary value

Parameters

integer $cat_ID

ID

integer $client_id

Client ID

Returns

integer

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

_get_tree()

_get_tree(integer  $client_id, integer|null  $parent_id = NULL) : array

Make a multidimensional array with information about docs.

Parameters

integer $client_id

Client ID.

integer|null $parent_id

Parent ID

Returns

array

save_model_data()

save_model_data(array  $data) 

Check if private var parent_id is setter & private var client_id is setter to concat on data array.

Parameters

array $data

Post Array