Skip to content
montaguethomas edited this page Oct 20, 2011 · 13 revisions

Protected Methods

Toggle Write Requires Primary Keys

void $this->_set_write_requires_pks(bool);

Toggle Use SQL Transactions

void $this->_set_use_transactions(bool);

Set the table of the Model

bool $this->_set_table($table);

Sets the fields of the Model automatically based off of $CI->db->list_fields()

bool $this->_set_fields();

Add new field to Model

bool $this->_add_field($field, $settings = array());

Set a setting value on a field of the Model

bool $this->_set_field_setting($field, $setting, $value);

Add a field validation to the Model

bool $this->_add_validate_field($field, $validation);

Set a field to be required for a certain operation of the Model

bool $this->_add_required_field($field, $operation = 'all');

Set a field to be protected from any updates from the Model

bool $this->_add_protected_field($field);

Add a primary key to the table of the Model

bool $this->_add_primary_key($field);

Add a foreign table relationship to this Model

bool $this->_add_foreign_table($table, $model, $foreign_keys, $insert = TRUE, $update = TRUE, $delete = TRUE, $cascade = FALSE);

Run a system check on the Model, DB table, and fields

bool $this->_run_check($check_table = FALSE, $check_fields = FALSE);

Run a system check on the DB table

bool $this->_check_table();

Run a system check on the fields

bool $this->_check_fields();

Public Methods

Get Number of Rows from last Query

int $this->num_rows();

Get Number of Affected Rows from last Query

int $this->affected_rows();

Generates the SELECT portion of the query

object $this->select($select = '*', $escape = NULL);

Generates a SELECT MAX(field) portion of a query

object $this->select_max($select = '', $alias = '');

Generates a SELECT MIN(field) portion of a query

object $this->select_min($select = '', $alias = '');

Generates a SELECT AVG(field) portion of a query

object $this->select_avg($select = '', $alias = '');

Generates a SELECT SUM(field) portion of a query

object $this->select_sum($select = '', $alias = '');

Sets a flag which tells the query string compiler to add DISTINCT

object $this->distinct($val = TRUE);

Generates the JOIN portion of the query

object $this->join($table, $cond, $type = '');

Generates the WHERE portion of the query. Separates multiple calls with AND

object $this->where($key, $value = NULL, $escape = TRUE);

Generates the WHERE portion of the query. Separates multiple calls with OR

object $this->or_where($key, $value = NULL, $escape = TRUE);

Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate

object $this->where_in($key = NULL, $values = NULL);

Generates a WHERE field IN ('item', 'item') SQL query joined with OR if appropriate

object $this->or_where_in($key = NULL, $values = NULL);

Generates a WHERE field NOT IN ('item', 'item') SQL query joined with AND if appropriate

object $this->where_not_in($key = NULL, $values = NULL);

Generates a WHERE field NOT IN ('item', 'item') SQL query joined with OR if appropriate

object $this->or_where_not_in($key = NULL, $values = NULL);

Generates a %LIKE% portion of the query. Separates multiple calls with AND

object $this->like($field, $match = '', $side = 'both');

Generates a NOT LIKE portion of the query. Separates multiple calls with AND

object $this->not_like($field, $match = '', $side = 'both');

Generates a %LIKE% portion of the query. Separates multiple calls with OR

object $this->or_like($field, $match = '', $side = 'both');

Generates a NOT LIKE portion of the query. Separates multiple calls with OR

object $this->or_not_like($field, $match = '', $side = 'both');

Sets the GROUP BY value

object $this->group_by($by);

Sets the HAVING value. Separates multiple calls with AND

object $this->having($key, $value = '', $escape = TRUE);

Sets the OR HAVING value. Separates multiple calls with OR

object $this->or_having($key, $value = '', $escape = TRUE);

Sets the ORDER BY value

object $this->order_by($orderby, $direction = '');

Sets the LIMIT value

object $this->limit($value, $offset = '');

Sets the OFFSET value

object $this->offset($offset);

Get Records

array|bool $this->get($where = NULL, $select = NULL, $order_by = NULL, $group_by = NULL, $limit = NULL, $offset = NULL, $join = NULL, $escape = TRUE, $auto_format = TRUE);

Get Record

array|bool $this->get_record($where = NULL, $select = NULL, $join = NULL, $escape = TRUE, $auto_format = TRUE);

Count Records

int|bool $this->count($where = NULL, $join = NULL, $escape = TRUE);

Record Exists

bool $this->record_exists($where = NULL, $join = NULL, $escape = TRUE);

Insert Record

array|bool $this->insert($data, $foreign_data = NULL, $defaults_override = FALSE, $do_foreign = TRUE, $override_transactions = NULL);

Insert Records

array|bool $this->insert_all($records, $defaults_override = FALSE, $do_foreign = TRUE, $override_transactions = NULL);

Update Record(s)

bool $this->update($data, $foreign_data = NULL, $defaults_override = FALSE, $do_foreign = TRUE, $override_transactions = NULL);

Update (Where) Record(s)

bool $this->update_where($data, $where = NULL, $foreign_data = NULL, $defaults_override = FALSE, $do_foreign = TRUE, $override_transactions = NULL, $escape = TRUE);

Update All Records

bool $this->update_all($records, $defaults_override = FALSE, $do_foreign = TRUE, $override_transactions = NULL);

Delete Record(s)

bool $this->delete($where, $do_foreign = TRUE, $override_transactions = NULL, $escape = TRUE);

Delete All Records

bool $this->delete_all($do_foreign = TRUE, $override_transactions = NULL);

Clone this wiki locally