Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Feb 12, 2012
1 parent 9ad5463 commit cccc267
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -91,4 +91,4 @@ You can bypass the validation by calling `skip_validation()` before an insert or
Contributors
------------

This model is based on Jamie Rumbelow's base model that was based on Phil Sturgeon's model.
This model is based on Jamie Rumbelow's base model: https://github.com/jamierumbelow/codeigniter-base-model
18 changes: 10 additions & 8 deletions libraries/MY_Model.php
Expand Up @@ -2,10 +2,7 @@
/**
* @name CodeIgniter Base Model
* @author Jens Segers
* @modified Jamie Rumbelow <http://jamierumbelow.net>
* @modified Phil Sturgeon <http://philsturgeon.co.uk>
* @modified Dan Horrigan <http://dhorrigan.com>
* @modified Adam Jackett <http://darkhousemedia.com>
* @contributor Jamie Rumbelow <http://jamierumbelow.net>
* @link http://www.jenssegers.be
* @license MIT License Copyright (c) 2011 Jens Segers
*
Expand Down Expand Up @@ -47,6 +44,7 @@ class MY_Model extends CI_Model {

/*
* The database table fields, used for filtering data arrays before inserting and updating
* If not set, an additional query will be made to fetch these fields
*/
protected $fields = array();

Expand Down Expand Up @@ -292,7 +290,7 @@ public function dropdown() {
}

/**
* Skip the insert validation
* Skip the insert validation for future calls
*/
public function skip_validation($bool = TRUE) {
$this->skip_validation = $bool;
Expand Down Expand Up @@ -345,7 +343,11 @@ private function _run_validation($data) {
}

/**
* Sets WHERE depending on the number of parameters
* Sets WHERE depending on the number of parameters, has 4 modes:
* 1. ($id) primary key value mode
* 2. (array("name"=>$name)) associative array mode
* 3. ("name", $name) custom key/value mode
* 4. ("id", array(1, 2, 3)) where in mode
*/
private function _set_where($params) {
if (count($params) == 1) {
Expand All @@ -367,7 +369,7 @@ private function _set_where($params) {
* Return or fetch the database fields
*/
private function _fields() {
if ($this->_table() && count($this->fields) == 0) {
if ($this->_table() && empty($this->fields)) {
$this->fields = $this->db->list_fields($this->_table());
}
return $this->fields;
Expand All @@ -384,4 +386,4 @@ private function _table() {
}
return $this->table;
}
}
}

0 comments on commit cccc267

Please sign in to comment.