Posted By

manteca on 12/29/09


Tagged

autoload codeigniter


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jatap


Codeigniter Autoload Model and Controlle


 / Published in: PHP
 

URL: http://net.tutsplus.com/tutorials/php/6-codeigniter-hacks-for-the-masters/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+nettuts+%28NETTUTS%29

Agregar este codigo al final de system/application/config/config.php

Entocnes en lugar de

Class Test extends Model --> Class Test

y en lugar de $this->load->model('test'); $this->test->some_function();

es $var = new Test; $var->some_function();

Esto permite utilizar las funciones de autocompletado de las IDE de desarrollo

  1. function __autoload($class) {
  2. if (file_exists(APPPATH."models/".strtolower($class).EXT)) {
  3. include_once(APPPATH."models/".strtolower($class).EXT);
  4. } else if (file_exists(APPPATH."controllers/".strtolower($class).EXT)) {
  5. include_once(APPPATH."controllers/".strtolower($class).EXT);
  6. }
  7. }

Report this snippet  

You need to login to post a comment.