ajtamwojtek
ajtamwojtek

Reputation: 763

Callback to model

I'm searching callback to model solution in CodeIgniter. I have found a few solutions, but all of them are deprecated. For example

Is possible any other solution to reach the intended effect ? I really have no idea ;x

Upvotes: 0

Views: 38

Answers (1)

Allende
Allende

Reputation: 1482

Have you tried to do something using call_user_func ? php.net/manual/en/function.call-user-func.php

http://php.net/manual/en/function.call-user-func.php

I'm not sure if you can callback to a model method, but per the documentation on PHP you can use nameSapce and call methods from a class:

<?php

class myclass {
    static function say_hello()
    {
        echo "Hello!\n";
    }
}

$classname = "myclass";

call_user_func(array($classname, 'say_hello'));
call_user_func($classname .'::say_hello'); // As of 5.2.3

$myobject = new myclass();

call_user_func(array($myobject, 'say_hello'));

?> 

Upvotes: 1

Related Questions