Welcome Guest, Not a member yet? Register   Sign In
Controller.php
#1

[eluser]marjune[/eluser]
Hi! I've been checked out the core in codeigniter and i came some interesting stuff that i couldn't seem understand. like in the Controller.php

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package  CodeIgniter
* @author  ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license  http://ellislab.com/codeigniter/user-guide/license.html
* @link  http://codeigniter.com
* @since  Version 1.0
* @filesource
*/

// ------------------------------------------------------------------------

/**
* CodeIgniter Application Controller Class
*
* This class object is the super class that every library in
* CodeIgniter will be assigned to.
*
* @package  CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author  ExpressionEngine Dev Team
* @link  http://ellislab.com/codeigniter/user-guide/general/controllers.html
*/
class CI_Controller {

private static $instance;

/**
  * Constructor
  */
public function __construct()
{
  self::$instance =& $this;
  
  // Assign all the class objects that were instantiated by the
  // bootstrap file (CodeIgniter.php) to local class variables
  // so that CI can run as one big super object.
  foreach (is_loaded() as $var => $class)
  {
   $this->$var =& load_class($class);
   //var_dump($this->$var);
   //print $var.' '.$class.' '.count(is_loaded()).'<br>';
  }

  $this->load =& load_class('Loader', 'core');
  $this->load->initialize();
  
  log_message('debug', "Controller Class Initialized");
}

public static function &get;_instance()
{
  return self::$instance;
}
}
// END Controller class

/* End of file Controller.php */
/* Location: ./system/core/Controller.php */

i know that this class CI can run as one big super object. so we can easily use like
Code:
$this->db->query();
$this->load->view();
$this->load->model();
$this->input->post();

and etc.. but some of the things i couldn't understand is like the
Code:
$this->db->query();

where in the hell in
Code:
function &load;_class()
in Common.php the db initialized like
Code:
$this->db = New CI_DB_mysql_driver
or in the Controller where the original class name is CI_DB_mysql_driver.. and same as in
Code:
$this->load->view; $this->load->model();
where the original class name of load is CI_Loader


thanks




Theme © iAndrew 2016 - Forum software by © MyBB