Also, to use the $c variable in the view, you need to set it in the 
controller:
$this->set('c', $this->M->getX());

http://book.cakephp.org/2.0/en/controllers.html#Controller::set



On Sunday, October 14, 2012 10:08:56 PM UTC-4, vinny M wrote:
>
> He's right seems like you made a mistake calling your method with the 
> wrong name :)
>
> VM 
>
> Sent from iPhone smartphone
>
> On 2012-10-14, at 9:54 PM, sutikno sofjan <[email protected]<javascript:>> 
> wrote:
>
> controller M code
>
> class M_controller extends AppController{
>
> $this->M->setM();  <<<<<<<<<< This is wrong. $this->M->setX();
>
> $c = $this->M->getX();
>
>
>
> }
>
>
> On Mon, Oct 15, 2012 at 12:57 AM, Ashish Mahana 
> <[email protected]<javascript:>
> > wrote:
>
>> if we declare a variable inside a model then we are unable to fetch its 
>> value in controller
>>
>> e.g.  
>>
>> Model M code:
>>
>> class M extends AppModel
>> {
>>    var $x;
>>
>>
>> function setX(){
>> $this->x = "hello";
>> }
>> function getX(){
>> return $this->x;
>> }
>>
>> }
>>
>>
>> controller M code
>>
>> class M_controller extends AppController{
>>
>> $this->M->setM();
>>
>> $c = $this->M->getX();
>>
>>
>>
>> }
>>
>> when i check the $c in view page its blank 
>>
>> can anybody explain what is happening over here
>>
>> -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> [email protected] <javascript:>.
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>  
>>  
>>
>
>  -- 
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>  
> --- 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]<javascript:>
> .
> To unsubscribe from this group, send email to 
> [email protected] <javascript:>.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>  
>  
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to