The code you pasted probably won't work.

$currentuserid=AuthComponent::user('id');  // Use $this->Auth->user('id') 
instead.

In the find you are using the user_id field as a condition but only returning 
the Teacher.id field - do the Teacher.id and Teacher.user_id fields contain the 
same value?

     $teacherid=$this->Teacher->find('first',array(
         'conditions' => array('Teacher.user_id' => $currentuserid),
          'fields' => array('Teacher.id'),
         ));

        if ( $teacherid==$id ){.........//never matches when it should

What's the point of doing a find using a known condition and checking that the 
result matches the condition you passed? If you want the Teacher.id value by 
searching in the Teacher.user_id field you should:

$teacherId = $this->Teacher->field('id, array('Teacher.user_id' => 
$currentUserId));

if (empty($teacherId) {
        // The current user does not have a row in the teachers table
}


On 3 Jun 2014, at 23:48, jagguy <and...@itfutures.edu.au> wrote:

> This is for a view?
> I know the book and have tried this already for a controller.
> 
> 
> 
> 
> P: (03) 9866 7737
> E: i...@itfutures.edu.au
> A: Suite 5 / Level 1 / 424 St Kilda Rd, Melbourne, 3004
> 
> 
> 
> Connect with us: 
> 
>     
> 
> Please consider the environment before printing this email.
>  
> This e-mail and any attachments to it (the "Communication") is, unless 
> otherwise stated, confidential,  may contain copyright material and is for 
> the use only of the intended recipient. If you receive the Communication in 
> error, please notify the sender immediately by return e-mail, delete the 
> Communication and the return e-mail, and do not read, copy, retransmit or 
> otherwise deal with it. Any views expressed in the Communication are those of 
> the individual sender only, unless expressly stated to be those of National 
> Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any of its 
> related entities. NTSP does not accept liability in connection with the 
> integrity of or errors in the Communication, computer virus, data corruption, 
> interference or delay arising from or in respect of the Communication.
> 
> -- 
> 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 unsubscribe from this group and stop receiving emails from it, send an 
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to