Helo there i am trying to call model from a variable

let say that i have a code is like this:

        // $model_name is a string
        // bind necessary model
        if(!empty($model_name)){
                $this->AreaInfo->bindModel(
                        array(
                                'belongsTo'=>array(
                                        $model_name => array(
                                                'className' => $model_name,
                                                'foreignKey' => 'reference_id'
                                                )
                                        )
                                )
                        );
                }

        $model_data = $this->AreaInfo->$model_name->find('list');    // **
this is my question
        print_r($model_data);

the $model_data variable now is not empty, but i got something like
this :

Array
(
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 4
    [5] => 5
    [6] => 6
    [7] => 7
    [8] => 8
    [9] => 9
    [10] => 10
    [11] => 11
    [12] => 12
    [13] => 13
    [14] => 14
    [15] => 15
    [16] => 16
    [17] => 17
    [18] => 18
    [19] => 19
    [20] => 20
)

Fatal error: Cannot access empty property in {some_directories_path}
\app\controllers\areas_controller.php on line **

is it possible to do such a thing like above? if yes or no please let
me know with your sugesstion :) ...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to