Now I am working with yii framework and I'd like to wrote something like this:
protected static $model = "Customer";
...
public function actionIndex() {
$model::model()->find(...
Now it works:
protected static $model = "Customer";
protected static $model_obj;
...
public function __construct($controller, $id) {
$this->model_obj = new self::$model;
...
public function actionIndex() {
$model_obj::model()->find(...
but creating object for access static member is a bad thing. how to avoid it?
getClass takes object as first parameter and it is not suitable for this purpose
google say:
$a = constant($myClassName . "::CONSTANT");
$b = call_user_func(array($myClassName, "static_method"));
it looks like a horrible peace of shit. using this may make many troubles. another solution?
oh! my problem was another:
$controller::$NAME::model() // error
$controller_name = $controller::$NAME
$controller_name::model() // good
thanks