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.

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

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

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

get_cats_branch(integer  $cat_id, array|null  $ret = null) : array

Make an array of categories Ids.

Parameters

integer $cat_id

Category id.

array|null $ret

Array

Returns

array

get_filtered_tree()

get_filtered_tree(array  $cats_ids, array  $docs_ids) : array

Make a multidimensional array with information about docs.

Parameters

array $cats_ids

Array of categories.

array $docs_ids

Array of documents

Returns

array

get_filtered_by_parent()

get_filtered_by_parent(array  $cats_ids, integer|null  $parent_id = NULL) : array

Fetch all the records in the table filtered by Array of categories and parent ID

Parameters

array $cats_ids

Array of categories.

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

_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

get_by_parent()

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

Fetch all the records in the table filtered by parent ID

Parameters

integer|null $parent_id

Parent ID

Returns

array

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 the primary key. Return an array

Parameters

integer $cat_ID

ID

Returns

array

setrepocategories()

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

updaterepocategories()

updaterepocategories(integer  $cat_ID, integer  $businesspartnerid, array  $data) : integer

Updated a record based on the primary value. Return affected rows

Parameters

integer $cat_ID

ID

integer $businesspartnerid

Business Partner ID

array $data

Post Data

Returns

integer

deleterepocategories()

deleterepocategories(integer  $cat_ID, integer  $businesspartnerid) : integer

Delete a row from the table by the primary value. Return affected rows

Parameters

integer $cat_ID

ID

integer $businesspartnerid

Business Partner 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

_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

_callback_table()

_callback_table() 

This callback runs on the read_table method.

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

_get_filtered_tree()

_get_filtered_tree(array  $cats_ids, array  $docs_ids, integer|null  $parent_id = NULL) : array

Make a multidimensional array with information about docs.

Parameters

array $cats_ids

Array of categories.

array $docs_ids

Array of documents

integer|null $parent_id

Parent ID

Returns

array

save_parent_id()

save_parent_id(array  $data) 

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

Parameters

array $data

Post Array

_default_image()

_default_image(array  $data) 

Check on provided array if image key is empty to retrieve from database based on business_partner key.

Parameters

array $data

Post Array