Re: Dynamic Model Call

2009-01-21 Thread Webweave

OK, I'm not sure why you are trying to do the late binding and use a
variable model name, but my guess would be that there is something
that hasn't been set up in the normal Cake magic of loading the code
that has caused something not to be initialized.

What is the rest of the stack for the error you are seeing (that
should show you where in the cake base classes the actual error is
happening)?

On Jan 21, 8:22 pm, Yusuf Widiyatmono  wrote:
> sorry it just a mark for the code line.
>
> Fatal error: Cannot access empty property in 
> {some_directories_path}\app\controllers\areas_controller.php on line **
>
> i mean that i got that message from this line
>
> $model_data = $this->AreaInfo->$model_name->find('list');    **
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 1:06:39 PM
> Subject: Re: Dynamic Model Call
>
> What is on line** (from the error msg)?
>
> On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono  wrote:
> > the model is loaded...
> > see the print_r result, the model can retrieve some data,
> > but in the end the error still appear and make the further logic die
>
> > 
> > From: brian 
> > To: cake-php@googlegroups.com
> > Sent: Thursday, January 22, 2009 12:30:22 PM
> > Subject: Re: Dynamic Model Call
>
> > Are these models loaded?
>
> > On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
> >> i did and it still shows me same errors...
>
> >> 
> >> From: brian 
> >> To: cake-php@googlegroups.com
> >> Sent: Thursday, January 22, 2009 2:49:31 AM
> >> Subject: Re: Dynamic Model Call
>
> >> Try $this->AreaInfo->{$model_name}->find(...)
>
> >> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>
> >>> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Model Call

2009-01-21 Thread brian

I don't think it's your english. I'm just confused that the find() can
fetch data, but also throw a fatal error, so I didn't understand the
question. Sorry, I don't think I can answer this.

Well, maybe if you change your code (after the bindModel() block) to:

Debugger::log($model_name);
$model_data = $this->AreaInfo->{$model_name}->find('list');
Debugger::log($model_data);

See what that outputs in the log, just as a sanity check.


On Thu, Jan 22, 2009 at 12:20 AM, Yusuf Widiyatmono  wrote:
> the error is happen because i use variable as model name
> $model_data = $this->AreaInfo->{$model_name}->find('list');
>
> but although its give me error and stop the php compile on that ** line
> its still could fetch data from that $model_name table..
> that is why the $model_data have value when i try to print it.
>
> my question is how to get rid this error?
>
> sorry for my bad english before :)
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 2:10:17 PM
> Subject: Re: Dynamic Model Call
>
>
> I don't think I understand what your question is, then. Yes, you can
> use a variable as the model name, if used the way I showed you. But,
> where did this error come from? If it was from the find() line, how is
> it that your array has data in it?
>
> On Wed, Jan 21, 2009 at 11:22 PM, Yusuf Widiyatmono 
> wrote:
>> sorry it just a mark for the code line.
>>
>> Fatal error: Cannot access empty property in
>> {some_directories_path}\app\controllers\areas_controller.php on line **
>>
>> i mean that i got that message from this line
>>
>> $model_data = $this->AreaInfo->$model_name->find('list');**
>>
>>
>>
>>
>>
>> 
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 1:06:39 PM
>> Subject: Re: Dynamic Model Call
>>
>>
>> What is on line** (from the error msg)?
>>
>> On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono 
>> wrote:
>>> the model is loaded...
>>> see the print_r result, the model can retrieve some data,
>>> but in the end the error still appear and make the further logic die
>>>
>>>
>>>
>>> 
>>> From: brian 
>>> To: cake-php@googlegroups.com
>>> Sent: Thursday, January 22, 2009 12:30:22 PM
>>> Subject: Re: Dynamic Model Call
>>>
>>>
>>> Are these models loaded?
>>>
>>> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono 
>>> wrote:
>>>> i did and it still shows me same errors...
>>>>
>>>>
>>>> 
>>>> From: brian 
>>>> To: cake-php@googlegroups.com
>>>> Sent: Thursday, January 22, 2009 2:49:31 AM
>>>> Subject: Re: Dynamic Model Call
>>>>
>>>>
>>>> Try $this->AreaInfo->{$model_name}->find(...)
>>>>
>>>> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>>>>
>>>>> 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 :

Re: Dynamic Model Call

2009-01-21 Thread Yusuf Widiyatmono
the error is happen because i use variable as model name
$model_data = $this->AreaInfo->{$model_name}->find('list');

but although its give me error and stop the php compile on that ** line
its still could fetch data from that $model_name table..
that is why the $model_data have value when i try to print it.

my question is how to get rid this error?

sorry for my bad english before :)




From: brian 
To: cake-php@googlegroups.com
Sent: Thursday, January 22, 2009 2:10:17 PM
Subject: Re: Dynamic Model Call


I don't think I understand what your question is, then. Yes, you can
use a variable as the model name, if used the way I showed you. But,
where did this error come from? If it was from the find() line, how is
it that your array has data in it?

On Wed, Jan 21, 2009 at 11:22 PM, Yusuf Widiyatmono  wrote:
> sorry it just a mark for the code line.
>
> Fatal error: Cannot access empty property in
> {some_directories_path}\app\controllers\areas_controller.php on line **
>
> i mean that i got that message from this line
>
> $model_data = $this->AreaInfo->$model_name->find('list');**
>
>
>
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 1:06:39 PM
> Subject: Re: Dynamic Model Call
>
>
> What is on line** (from the error msg)?
>
> On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono 
> wrote:
>> the model is loaded...
>> see the print_r result, the model can retrieve some data,
>> but in the end the error still appear and make the further logic die
>>
>>
>>
>> ____
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 12:30:22 PM
>> Subject: Re: Dynamic Model Call
>>
>>
>> Are these models loaded?
>>
>> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono 
>> wrote:
>>> i did and it still shows me same errors...
>>>
>>>
>>> 
>>> From: brian 
>>> To: cake-php@googlegroups.com
>>> Sent: Thursday, January 22, 2009 2:49:31 AM
>>> Subject: Re: Dynamic Model Call
>>>
>>>
>>> Try $this->AreaInfo->{$model_name}->find(...)
>>>
>>> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>>>
>>>> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Model Call

2009-01-21 Thread brian

I don't think I understand what your question is, then. Yes, you can
use a variable as the model name, if used the way I showed you. But,
where did this error come from? If it was from the find() line, how is
it that your array has data in it?

On Wed, Jan 21, 2009 at 11:22 PM, Yusuf Widiyatmono  wrote:
> sorry it just a mark for the code line.
>
> Fatal error: Cannot access empty property in
> {some_directories_path}\app\controllers\areas_controller.php on line **
>
> i mean that i got that message from this line
>
> $model_data = $this->AreaInfo->$model_name->find('list');**
>
>
>
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 1:06:39 PM
> Subject: Re: Dynamic Model Call
>
>
> What is on line** (from the error msg)?
>
> On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono 
> wrote:
>> the model is loaded...
>> see the print_r result, the model can retrieve some data,
>> but in the end the error still appear and make the further logic die
>>
>>
>>
>> ________
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 12:30:22 PM
>> Subject: Re: Dynamic Model Call
>>
>>
>> Are these models loaded?
>>
>> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono 
>> wrote:
>>> i did and it still shows me same errors...
>>>
>>>
>>> 
>>> From: brian 
>>> To: cake-php@googlegroups.com
>>> Sent: Thursday, January 22, 2009 2:49:31 AM
>>> Subject: Re: Dynamic Model Call
>>>
>>>
>>> Try $this->AreaInfo->{$model_name}->find(...)
>>>
>>> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>>>
>>>> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Model Call

2009-01-21 Thread Yusuf Widiyatmono
sorry it just a mark for the code line. 

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

i mean that i got that message from this line

$model_data = $this->AreaInfo->$model_name->find('list');**






From: brian 
To: cake-php@googlegroups.com
Sent: Thursday, January 22, 2009 1:06:39 PM
Subject: Re: Dynamic Model Call


What is on line** (from the error msg)?

On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono  wrote:
> the model is loaded...
> see the print_r result, the model can retrieve some data,
> but in the end the error still appear and make the further logic die
>
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 12:30:22 PM
> Subject: Re: Dynamic Model Call
>
>
> Are these models loaded?
>
> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
>> i did and it still shows me same errors...
>>
>>
>> 
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 2:49:31 AM
>> Subject: Re: Dynamic Model Call
>>
>>
>> Try $this->AreaInfo->{$model_name}->find(...)
>>
>> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>>
>>> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Model Call

2009-01-21 Thread brian

What is on line** (from the error msg)?

On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono  wrote:
> the model is loaded...
> see the print_r result, the model can retrieve some data,
> but in the end the error still appear and make the further logic die
>
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 12:30:22 PM
> Subject: Re: Dynamic Model Call
>
>
> Are these models loaded?
>
> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
>> i did and it still shows me same errors...
>>
>>
>> 
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 2:49:31 AM
>> Subject: Re: Dynamic Model Call
>>
>>
>> Try $this->AreaInfo->{$model_name}->find(...)
>>
>> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>>
>>> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Model Call

2009-01-21 Thread Yusuf Widiyatmono
the model is loaded...
see the print_r result, the model can retrieve some data, 
but in the end the error still appear and make the further logic die


 





From: brian 
To: cake-php@googlegroups.com
Sent: Thursday, January 22, 2009 12:30:22 PM
Subject: Re: Dynamic Model Call


Are these models loaded?

On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
> i did and it still shows me same errors...
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 2:49:31 AM
> Subject: Re: Dynamic Model Call
>
>
> Try $this->AreaInfo->{$model_name}->find(...)
>
> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>
>> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Model Call

2009-01-21 Thread brian

Are these models loaded?

On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
> i did and it still shows me same errors...
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 2:49:31 AM
> Subject: Re: Dynamic Model Call
>
>
> Try $this->AreaInfo->{$model_name}->find(...)
>
> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>
>> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Model Call

2009-01-21 Thread Yusuf Widiyatmono
i did and it still shows me same errors...

 





From: brian 
To: cake-php@googlegroups.com
Sent: Thursday, January 22, 2009 2:49:31 AM
Subject: Re: Dynamic Model Call


Try $this->AreaInfo->{$model_name}->find(...)

On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>
> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Model Call

2009-01-21 Thread brian

Try $this->AreaInfo->{$model_name}->find(...)

On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>
> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Dynamic Model Call

2009-01-21 Thread wmonou

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---