[eluser]metaltapimenye[/eluser]
soory for my english..
when i got latest version of CI (1.7.1), i realize there's something change with models load protocol even it might be happen long on older versions. when i do this in my model, some coding style meet its limitation..
Code:
//location:/application/models/one.php
//retrieve protocol:$this->one->get_something();
class one extends Model {
function one()
{
parent::Model();
#$this->load->model('two'); # if this line uncommented, everything works just fine
}
function get_something(){
$this->load->model('two'); # <-- getting other models, will result 'two' object not identified. kind of bush in the throat uh?
return $this->two->get_method_two(); #<-- generating error
}
}
yes,
& get_instance() stuff will make it work. but hey, it just models->models layer transaction, why should dig too deep?
for short term project it would not be a problem, but if we working a huge and long term project .. it might make some models wont work after upgrade, and yes, it could be a pain in the ass to fix it.
yesterday, i make some tryouts on CI 1.7.1
Controller:
Code:
class Blog extends Controller {
function Blog(){
parent::Controller();
}
function index(){
$this->load->view('view_page');
}
}
View:
Code:
<!--html stuff-->
<?php
$this->load->model('blog_model','blog');
echo $this->blog->header();
echo $this->blog->content();
?>
<br>
<?php $this->load->view('other');
echo $this->blog->footer();
?>
...
and work as a charm.
it would be a pleasure for an old cowboy like me to applying this coding style. But i reminded by the way loading model->model and i might pissed when i upgrade which is not allow me to do some stuff like this way.
in best practice, how's models loaded should be in MVC pattern?