• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
call_user_func problem....

#1
[eluser]Unknown[/eluser]
Hello !

I'm trying to write some kind scheduler/Cron library for my CI project. Now i'm stuck with call_user_func.


Jobs are stored in MySQL Db in format:

Code:
library name | method name(job) | params

Everything are stored as strings. I want to load libraries with $this->load->.... construction.

My question is, how can i invoke specified method from specified library ????

This construction won't work:

Code:
foreach ($q->result_array() as $r) {
    $this->CI->load->library($n);
    call_user_func( array($this, $this->CI->$r['library']->$r['job']), $r['params']);
}

#2
[eluser]Unknown[/eluser]
Heh, solution found:

Code:
$this->CI->load->library($r['library']);
$this->CI->{strtolower($r['library'])}->{strtolower($r['job'])}($r['params']);


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.