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
