There is a typo here. Do you have a table named port_groups_entity,
sport_groups_entities?  The errors should be followable.
   array(
           'table' => 'port_groups_entity',

You also seem to be  using some odd names on your tables.  I try to always
avoid using two plurals unless that table is a join table (habtm) for two
other tables.   If I do has association through tables, I name that table
logically for the relationship that it has.   Such as students, classrooms,
has a join table enrollments that has extra data based the many to many.

You should debug($var) on all of your variables to see what is actually
there.


On Sun, Feb 5, 2012 at 1:41 PM, Team Kemster
<[email protected]>wrote:

> Hi Stephen,
>
> Thank you for your answer.
>
> Well I would say you are right, if it wasn't for that I am able to
> use both the tables for it's self. But joining them gives the problems.
>
> I also tried to use some examples on binding the tables with a model for
> both tables, but no luck.
>
> Yes, the table has "name" for a column (tables shown in first mail).
>
> Is the pull out in the ctp files correct?
>
> /TheMuller
>
> Den 05/02/2012 kl. 18.54 skrev Stephen Speakman <
> [email protected]>:
>
> > Hi
> >
> > I may not know the answer to your question but shouldn't your model be
> named:
> >
> > sport_group.php and SportGroup extends AppModel ?
> >
> > port_groups_entity table should be named "port_group_entities"  ----
> PortGroupEntities
> >
> > I would personally correct all the filenames, class names and
> $this->Model lines etc to represent proper CakePHP conventions, then I
> would use pr($this->SportGroup->findByUrl($url)); etc to view the results
> retrieved from the query...
> >
> > If name isn't in there maybe it's an error with your MySQL table? Maybe
> check recursive? (Apologies if I missed any info, my thunderbird client
> isn't threading mail list topics =/)
> >
> > Kind Regards
> > Stephen
> >
> >
> > On 05/02/2012 17:18, TheMuller wrote:
> >> Hi,
> >>
> >> I have looked, search and founded, but not the answer to my questions:
> >> How do I get the result of my join table in my view.ctp? Am I doing
> >> something wrong?
> >>
> >> I have followed some guides from bakery and other blogs, and created a
> >> setup like shown below. But why does the error in view.ctp say:
> >> "Notice (8): Undefined index:  name"
> >>
> >> Code:
> >>
> >> models/sportsgroup.php
> >> <?php
> >> class SportsGroup extends Appmodel {
> >>     var $name = 'SportsGroup';
> >> }
> >> ?>
> >>
> >> controllers/sports_groups_controllers.php
> >> <?php
> >>
> >> class SportsGroupsController extends AppController {
> >>     var $helpers = array ('Html', 'Form', 'Js' =>  array('Jquery'),
> >> 'Javascript', 'GoogleMapView');
> >>     var $name = 'SportsGroups';
> >>
> >>     function index() {
> >>       $this->SportsGroup->recursive = 0;
> >>       $this->set('sportsgroups', $this->SportsGroup->find('all',
> >> array('joins' =>  array(
> >>         array(
> >>             'table' =>  'port_groups_entity',
> >>             'alias' =>  'GroupsEntity',
> >>             'type' =>  'inner',
> >>             'conditions'=>  array('SportsGroup.group_id =
> >> GroupsEntity.guid')
> >>             )
> >>         )
> >>         )));
> >>       $this->set('title_for_layout', 'Sportsclubs online');
> >>
> >>     }
> >>     function view($url = null) {
> >>     if (!$url) {
> >>         $this->Session->setFlash('Invalid id for Post.');
> >>         $this->redirect('/sportsclub/');
> >>     }
> >>     $this->set('post', $this->SportsGroup->findByUrl($url));
> >>     }
> >> }
> >>
> >> ?>
> >>
> >> view/sportsgroups/index.ctp (or view.ctp)
> >> <?php foreach ($sportsgroups as $post): ?>
> >> <?php echo $post['SportsGroup']['title']?>  (it catches this one)
> >> <?php echo $post['SportsGroup']['name']?>  (but not this one)
> >> <?php endforeach; ?>
> >>
> >> view/sportsgroups/view.ctp
> >> <?php echo $post['SportsGroup']['title']?>  (it catches this one)
> >> <?php echo $post['SportsGroup']['name']?>  (but not this one)
> >>
> >> The database table are like:
> >> sports_groups: id | group_id | title
> >> groups_entity: guid | name
> >>
> >> Please help me, I used 2-3 days on this one..
> >>
> >> /TheMuller
> >>
> >
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org Check out the new CakePHP Questions site
> http://ask.cakephp.org and help others with their CakePHP related
> questions.
> >
> >
> > To unsubscribe from this group, send email to
> > [email protected] For more options, visit this
> group at http://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to