Welcome Guest, Not a member yet? Register   Sign In
Tip: Sick of get_instance()?
#11

[eluser]Mackstar[/eluser]
Code Igniters limitation of the CI super object is one of the things that seem to give it such a speed advantage, I am sure that over-use of importing it will slow down apps somewhat. But never to the extent of Cake I am sure?

I would love to hear if anyone has any performance benchmarks of cases invoking the Super Object and not... Memory usage would also be an issue I am sure..
#12

[eluser]Lima[/eluser]
Is it work on PHP 4?
#13

[eluser]Dam1an[/eluser]
I havn't run any benchmarks on this approach, but if you plan on using this many times in a single helper function, then I would recomend just assigning the CI super object to a variable, as the overhead of making multiple calls would probably impact performance, although I'd imagine it would only make a nticable difference if you did it many, many times.

@Lima: Although the function itself would work in PHP4, the example of doing CI()->something() wouldn't, as method chaining only works in PHP5+
#14

[eluser]louis w[/eluser]
If you want to use this under PHP4 or worried about performance from multiple calls to it (I agree with Dam1an that this would only happen if you used it ALOT) you can do it like below. This really doesn't do anything above the normal get_instance besides make your code look prettier and save you from having to check if it exists all the time.

Code:
$CI = CI();




Theme © iAndrew 2016 - Forum software by © MyBB