reuse varibale in model - 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: reuse varibale in model (/showthread.php?tid=24090) |
reuse varibale in model - El Forum - 10-30-2009 [eluser]Russell Keith[/eluser] I have the follwing variable declared in every function in my model: $client = new soapclient("http://localhost:9090/summit/3440-TRAIN/services/CmdSpectrum?wsdl"); I would like to only declare it in one place and reuse it but I can't seem to find the correct location. Any help would be great. reuse varibale in model - El Forum - 10-30-2009 [eluser]jedd[/eluser] [quote author="Russell Keith" date="1256934083"] I have the follwing variable declared in every function in my model: $client = new soapclient("http://localhost:9090/summit/3440-TRAIN/services/CmdSpectrum?wsdl"); I would like to only declare it in one place and reuse it but I can't seem to find the correct location. Any help would be great. [/quote] If you truly have just the one model, declare it in your constructor. If you have multiple models and you want it in all of them, extend the core model - using the MY_Model thing in /application/libraries/ - see the manual for 'extending core libraries'. reuse varibale in model - El Forum - 10-30-2009 [eluser]Russell Keith[/eluser] I have tried: Code: function MPw() but the variable is not available in the subsequent functions. reuse varibale in model - El Forum - 10-30-2009 [eluser]jedd[/eluser] Code: $this->client = new soapclient("http://localhost:9090/summit/3440-TRAIN/services/CmdSpectrum?wsdl"); reuse varibale in model - El Forum - 10-30-2009 [eluser]Russell Keith[/eluser] That is amazing. This should be included in the User Guide. Thank you very much!! reuse varibale in model - El Forum - 10-30-2009 [eluser]Colin Williams[/eluser] It is amazing. And it's just vanilla PHP. It's not the user guide's job to document PHP. |