admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
| 2 | /** |
| 3 | * Code Igniter |
| 4 | * |
| 5 | * An open source application development framework for PHP 4.3.2 or newer |
| 6 | * |
| 7 | * @package CodeIgniter |
| 8 | * @author Rick Ellis |
| 9 | * @copyright Copyright (c) 2006, pMachine, Inc. |
| 10 | * @license http://www.codeignitor.com/user_guide/license.html |
| 11 | * @link http://www.codeigniter.com |
| 12 | * @since Version 1.0 |
| 13 | * @filesource |
| 14 | */ |
| 15 | |
| 16 | // ------------------------------------------------------------------------ |
| 17 | |
| 18 | /** |
| 19 | * Code Igniter Model Class |
| 20 | * |
| 21 | * @package CodeIgniter |
| 22 | * @subpackage Libraries |
| 23 | * @category Libraries |
| 24 | * @author Rick Ellis |
| 25 | * @link http://www.codeigniter.com/user_guide/libraries/config.html |
| 26 | */ |
| 27 | class Model { |
| 28 | |
| 29 | /** |
| 30 | * Constructor |
| 31 | * |
| 32 | * @access public |
| 33 | */ |
| 34 | function Model() |
| 35 | { |
| 36 | $this->_assign_libraries(FALSE); |
| 37 | log_message('debug', "Model Class Initialized"); |
| 38 | } |
| 39 | // END Model() |
| 40 | |
| 41 | /** |
| 42 | * Assign Libraries |
| 43 | * |
| 44 | * Creates local references to all currently instantiated objects |
| 45 | * so that any syntax that can be legally used in a controller |
| 46 | * can be used within models. |
| 47 | * |
| 48 | * @access private |
| 49 | */ |
| 50 | function _assign_libraries($use_reference = TRUE) |
| 51 | { |
| 52 | $obj =& get_instance(); |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 53 | foreach (get_object_vars($obj) as $key => $var) |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 54 | { |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 55 | if (is_object($var) AND ! isset($this->$key)) |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 56 | { |
| 57 | if ($use_reference === TRUE) |
| 58 | { |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 59 | $this->$key =& $obj->$key; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 60 | } |
| 61 | else |
| 62 | { |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 63 | $this->$key = $obj->$key; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 64 | } |
| 65 | } |
| 66 | } |
admin | e79dc71 | 2006-09-26 03:52:45 +0000 | [diff] [blame] | 67 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 68 | } |
| 69 | // END _assign_libraries() |
| 70 | |
| 71 | } |
| 72 | // END Model Class |
| 73 | ?> |