summaryrefslogtreecommitdiffstats
path: root/system/core/Model.php
diff options
context:
space:
mode:
authorGreg Aker <greg.aker@ellislab.com>2010-11-10 21:44:35 +0100
committerGreg Aker <greg.aker@ellislab.com>2010-11-10 21:44:35 +0100
commit00c05455d617ef635715163ada4ccf4a22abf394 (patch)
tree78d1d14371f64fb3fb1f8266752abb23daa556d0 /system/core/Model.php
parent4abfa686ca53177b7dbbb7e1bac3febbbe27ec0f (diff)
parent287781e13232b9d8289e14b4f9642d088ed13d01 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniterNoPhp4/
Diffstat (limited to 'system/core/Model.php')
-rw-r--r--system/core/Model.php40
1 files changed, 6 insertions, 34 deletions
diff --git a/system/core/Model.php b/system/core/Model.php
index ebbb0fbe6..f6098d0cf 100644
--- a/system/core/Model.php
+++ b/system/core/Model.php
@@ -26,57 +26,29 @@
*/
class CI_Model {
- var $_parent_name = '';
-
/**
* Constructor
*
* @access public
*/
- function CI_Model()
+ function __construct()
{
- // If the magic __get() or __set() methods are used in a Model references can't be used.
- $this->_assign_libraries( (method_exists($this, '__get') OR method_exists($this, '__set')) ? FALSE : TRUE );
-
- // We don't want to assign the model object to itself when using the
- // assign_libraries function below so we'll grab the name of the model parent
- $this->_parent_name = ucfirst(get_class($this));
-
log_message('debug', "Model Class Initialized");
}
/**
- * Assign Libraries
+ * __get
*
- * Creates local references to all currently instantiated objects
- * so that any syntax that can be legally used in a controller
- * can be used within models.
+ * Allows models to access CI's loaded classes using the same
+ * syntax as controllers.
*
* @access private
*/
- function _assign_libraries($use_reference = TRUE)
+ function __get($key)
{
$CI =& get_instance();
- foreach (array_keys(get_object_vars($CI)) as $key)
- {
- if ( ! isset($this->$key) AND $key != $this->_parent_name)
- {
- // In some cases using references can cause
- // problems so we'll conditionally use them
- if ($use_reference == TRUE)
- {
- // Needed to prevent reference errors with some configurations
- $this->$key = '';
- $this->$key =& $CI->$key;
- }
- else
- {
- $this->$key = $CI->$key;
- }
- }
- }
+ return $CI->$key;
}
-
}
// END Model Class