Welcome Guest, Not a member yet? Register   Sign In
calling get_instance() from external script
#1

[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.
#2

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

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

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

[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?
#6

[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.
#7

[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!




Theme © iAndrew 2016 - Forum software by © MyBB