CodeIgniter Forums
calling get_instance() from external script - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: calling get_instance() from external script (/showthread.php?tid=12250)



calling get_instance() from external script - El Forum - 10-12-2008

[eluser]Yednotek[/eluser]
Is it possible to get a CI instance in an external script somehow like this:

Code:
function somefunction_in_standalone_script()
{
  $obj=&get;_instance();
}

The external script is an 3rd party script that generates an image but it uses sessions which I already use in CI. If the above is possible then this would be the easiest solution.


calling get_instance() from external script - El Forum - 10-12-2008

[eluser]fatnic[/eluser]
I'm not sure but one solution maybe to use database sessions and then just query that table.


calling get_instance() from external script - El Forum - 10-12-2008

[eluser]Tom Glover[/eluser]
It should be possible if you include one of the CI core files, eg index.php the call it.


calling get_instance() from external script - El Forum - 10-12-2008

[eluser]Michael Wales[/eluser]
As long as the third-party script is called from CodeIgniter (like a controller), then yes.


calling get_instance() from external script - El Forum - 10-12-2008

[eluser]Yednotek[/eluser]
Quote:As long as the third-party script is called from CodeIgniter (like a controller), then yes.

The script returns an image, it is placed in the src="" parameter of an image tag so it is not called from a controller.

Quote:It should be possible if you include one of the CI core files, eg index.php the call it.

If I include my main index.php in the beginning of the script, then my whole webpage is returned as output plus the image.. Is there another file I can include so that only the core CI files are loaded without returning any output?


calling get_instance() from external script - El Forum - 10-12-2008

[eluser]Michael Wales[/eluser]
Quote:The script returns an image, it is placed in the src=”“ parameter of an image tag so it is not called from a controller.

Sounds like a helper to me, which you would load within the Controller and just call from your Views.


calling get_instance() from external script - El Forum - 10-12-2008

[eluser]Yednotek[/eluser]
Looks like I'll have to go in that direction.. It's been a while since I coded for CI so was looking for a quick fix Wink

Thanks for the help guys!