I always hear CodeIgniter is very light-weight !!! - please check this

#1
[eluser]venugopal[/eluser]
Newbie to CI and just tried to dump one of my Model Object.
Weird to see the dump

Model has Config, Input, Benchmark, Uri, Output, Lang, Router , Session embedded into it. Why should my Model object contain Input, Uri, Output, Router in it.

The biggest problem is again some of them are recursively embedded , like Session has Config ,Config has Uri, Uri has again Session....like this so many recuresively embedded.

No wonder CI takes so much of Memory for every HTTP Request. Is it the same way all MVC Frameworks are implemented. Or Am I am wrong in anyway here?

#2
[eluser]WanWizard[/eluser]
You are wrong.

All these variables are references to the same object, so they occupy memory only once (and you need a bit of memory for each pointer).
If you want to know what is using memory, run an xdebug session, and you'll know it exactly.

#3
[eluser]venugopal[/eluser]
cool makes sense Smile
But any idea why should Model has a reference to URI,OUTPUT,ROUTER etc..

#4
[eluser]WanWizard[/eluser]
These references are added when you load the model.

In the Model controller (the one you extend) there's a _assign_libraries() method that is called after instantiating the model class, and that will assign all loaded CI libraries to the model so they can be accessed via $this.

Code:
// without automatic assignments
$CI =& get_instance();
$CI->load->library('test');

// with automatic assignments
$this->load->library('test');

Just for convenience basically.

#5
[eluser]venugopal[/eluser]
Convenience is there - but again CI doesnt enforce strict MVC - "Don't do anything in Model other than what should be done"...anyways thanks for the replies.

#6
[eluser]WanWizard[/eluser]
So, according to "Strict MVC", you are not allowed to use libraries in models?

#7
[eluser]venugopal[/eluser]
Why do you need access to Router,Uri in Model. Arguments are always there on this, different views of different programmers

#8
[eluser]mddd[/eluser]
For instance, I have a site that allows the user to search on different parameters.
I created a model to analyze the uri to see which search options are active.
There's a reason to want to look at the URI in a model.

#9
[eluser]WanWizard[/eluser]
There is an encypt library that I need for all queries that involve encrypted of hashed fields. Do I have to replicate the same methods in all my models, or use a generic library?

As with many other elements of programming: the fact that something exists or something is possible doesn't mean you have to use it. Take for example the CI program guidelines. Not enforced, but recommended.
If you don't like using libraries in your models, then don't. But don't complain the framework allows you to use them.

If you need a strict framework to keep you on the right path, I guess as a programmer you're not mature enough.

#10
[eluser]BrianL[/eluser]
Like all things in life it is only as fast and as good as the skill of the programmer. It is also only as secure as the programmer.

For example, many developers turn on xss_clean permanently because they don't want to go through the bother of filtering output. But this is actually inefficient and wrong, since xss should be removed on output not removed from everything. Text must be processed before output and should not be blindly trusted just because it comes from a database. Of course CI lets you do whatever you want. Another example is htmlentities. Many developers do not understand paramaterized queries so they use htmlentities on everything, fearful of certain characters, and write manual SQL queries. Of course they are really attempting to mask their lack of understanding of character encoding and should be using ESAPI instead of inventing their own security controls, since hackers are quite devious and can not only double encode but bury encoding and exploit PHP library vulnerabilities (for example there was a shocking vulnerability in htmlentities allowing remote code execution just a couple PHP versions ago, and htmlentities is vulnerable if you don't specify the encoding). But again CI lets you do whatever you want. Prepared statements are the way to go but most developers don't understand prepared statements so CI makes available Active Record. Of course every single day there's people posting about manual SQL rather than using Active Record and they probably disable Active Record to get more efficient without actually realizing they are writing totally insecure code.

If you think CI is slow check out some bloated frameworks like CakePHP.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.