Looking at your post, I am not sure whether you are stating that you
have the following tables or models, because your naming of the
tables, does not conform to the CakePHP conventions:
http://book.cakephp.org/view/901/CakePHP-Conventions

Your tables should be in plural and lowercase:
tags, images, students, images_tags (not tags_images),
images_students.

Your models should be in singular and camelcase:
Tag, Image, Studen, ImageTag, ImageStudent.

As an aside I suggest you look into the Containable behaviour at:
http://book.cakephp.org/view/1323/Containable

Using the Containable behaviour will save you for a lot of trouble
retrieving related information in the future.

Back to finding your information (images with tag and student) based
on a tag name and a student id.

[code]
$this->Image->find(
   'all', array(
      'contains' => array(
         'Tag' => array(
            'conditions' => array(
               'Tag.tag_name' => $yourTagNameCriteria
            )
         ),
         'Student' => array(
            'conditions' => array(
               'Student.id' => $yourStudentCriteria
            )
         )
      )
   )
);
[/code]

The code is an example only, no guarantee that it will even be
correct :)
Enjoy,
   John

On May 16, 10:24 am, Dilip Godhani <[email protected]> wrote:
> I have five following table
>
> Tag  --- id,tag_name
>
> Image -- id,image_name
>
> Student-- id,fname,lname
>
> tag_image--id,image_id,tag_id
>
> Image_student ---id,image_id,student_id
>
> I want to find record using tag_name and student_id can anyone help me
> how i give relationship in model ,also i try following example,can any
> one give me manual query for that...!
>
> http://stackoverflow.com/questions/2827372/relationship-problem
>
> Thanks...!!!
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> 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 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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