Multiple method calls from library |
Hi there,
I would like to know how can I call two methods from library in a loop? For example I have library called "Test" and I load it in my controller PHP Code: $this->load->library('test'); I have array with values, for example: PHP Code: $values = array(10, 20, 30, 40, 50); Now I have to loop through that array and call two methods from my library: PHP Code: foreach($values as $value) { My problem is that after the first call of these methods I can see returned value but after that I'm not getting any remaining values. How can I achieve that in CodeIgniter?
Try making your $value array static.
You will then need a clear method to reset it. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Thanks for yours reply. This is example of my library:
PHP Code: defined('BASEPATH') OR exit('No direct script access allowed'); InsiteFX, do you mean something like this: PHP Code: defined('BASEPATH') OR exit('No direct script access allowed');
Yes, but like I said you will need to create a clear method to reset your value array.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
you mean like this?
try to re-write tour library to : PHP Code: class Test
Caffeine IT Solutions | Bina Darma University
(11-06-2016, 06:44 PM)ramadhansutejo Wrote: you mean like this? Thanks for reply, I made a mistake and tried to extend CI_Controller in my library. Also I forgot that if I need to use CodeIgniter resources I can't extend it but I have to assign CodeIgniter object to variable by reference like you do. Regards, ManOfHonor |
Welcome Guest, Not a member yet? Register Sign In |