CodeIgniter Forums
MVC Question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: MVC Question (/showthread.php?tid=18164)

Pages: 1 2


MVC Question - El Forum - 04-27-2009

[eluser]codeman[/eluser]
Hi Guys,

When you say that Code-Igniter uses the MVC approach and calls things only when needed makes it faster and less bulky

Does that mean when i When i use this http://localhost/index.php/blog/name - it only performs name(), or comment() or index(). It does not load the whole blog page?

Is this true? Does it load the whole page? if yes then what you mean by loading things when needed?

Code:
<?php
class Blog extends Controller {
    
    function __contruct(){
        parent::Controller;
    }
    
    function index()
    {
        echo 'Hello World!';
    }

    function comment(){
        echo "Comments are shown below";
    }
    
    function name(){
        echo "Put you Name";
    }
}
?>



MVC Question - El Forum - 04-27-2009

[eluser]Thorpe Obazee[/eluser]
What do you mean by 'not load the whole blog page'?

Code:
http://localhost/index.php/blog/name
would run, blog/name, yes.

Loading things when needed is because you can load libraries and helpers like, the cart, ftp, image manilapulation, etc as your are executing via $this->load.

That's probably one of the reasons why it's so fast. less automagic unlike 'Cake'.


MVC Question - El Forum - 04-27-2009

[eluser]NogDog[/eluser]
The blog.php controller file would be included, so if that's what you mean by "loaded", then yes, it is "loaded"; but only the __construct() and name() methods would be executed (unless either of those methods executed other methods).


MVC Question - El Forum - 04-27-2009

[eluser]Thorpe Obazee[/eluser]
OT: Hmm.. 2 dogs one page :p


MVC Question - El Forum - 04-27-2009

[eluser]NogDog[/eluser]
[quote author="bargainph" date="1240899925"]OT: Hmm.. 2 dogs one page :p[/quote]
Wanna make puppies? Wink

(Actually, since Noggin is neutered, that may be a bit difficult regardless of whether or not your dog is female. :bug: )


MVC Question - El Forum - 04-27-2009

[eluser]Thorpe Obazee[/eluser]
[quote author="NogDog" date="1240904671"]
(Actually, since Noggin is neutered, that may be a bit difficult regardless of whether or not your dog is female. :bug: )[/quote]

aaawww...

rofl.


MVC Question - El Forum - 04-27-2009

[eluser]Zeeshan Rasool[/eluser]
Nice question, look blog loads the page/view which you're given,so we have to load some data or have to show some record according to our function.So, comments() will load comments of blogs in view and same is with name().


MVC Question - El Forum - 04-28-2009

[eluser]xwero[/eluser]
codeman if you are talking about the physical loading of files the whole blog.php file is loaded. MVC doesn't do magical tricks.


MVC Question - El Forum - 04-28-2009

[eluser]Dam1an[/eluser]
I think the original question was refering more to the fact that CI doesn't load the entire stack (all the libraries, helpers etc) for you, but only the parts that you need (and specify)


MVC Question - El Forum - 04-28-2009

[eluser]Thorpe Obazee[/eluser]
[quote author="Dam1an" date="1240923141"]I think the original question was refering more to the fact that CI doesn't load the entire stack (all the libraries, helpers etc) for you, but only the parts that you need (and specify)[/quote]

Yep. that was what I think he was trying to say.