Ive read the pdf but i dont expect a pdf to tell me everything ;) and
i know how it worked 2 weeks ago (sorry - vacations ;) from the
beggining of the 'with' existance :)
So 2 weeks ago you had/should create a model for use with 'with' key.
If you would looks at 
http://api.cakephp.org/1.2/dbo__source_8php-source.html#l01108
then everything should be clearer.
greets,


On Aug 20, 6:53 pm, DLMax <[EMAIL PROTECTED]> wrote:
> If you read the PDF, written by phpnut, that doekie linked to, you see
> that no model has to be created for the join-table in the HABTM
> relation.
>
> You can get the HABTM to work like this:
> Post Model:
> <?php
>
> class Post extends AppModel {
>         var $name='Post';
>
>         var $hasAndBelongsToMany = array(
>                 'Tag' => array('className' => 'Tag'));
>
>     function beforeSave() {
>         if(!empty($this->data['Tag'])) {
>           $this->PostTag->save($this->data['Tag']);
>          }
>     }
>
> }
>
> Posts Controller:
> <?php
> class PostsController extends AppController {
>
>         var $name = 'Posts';
>         var $helpers = array('Html', 'Form' );
>
>         function tags() {
>                 $this->set('tags', $this->Post->PostTag->findAll());
>         }}
>
> ?>
> Tags view:
> <?php
>         pr($tags);
>         foreach ($tags as $tag) :
>                 echo $tag['Post']['title'];
>                 echo $tag['Tag']['name'];
>                 echo $tag['PostTag']['date'];
>         endforeach;
> ?>
>
> You can access the date field from the posts_tags table right now, but
> the beforesafe errors on saving a post and the Post and Tag are not
> accessible from the view.
>
> Any further help would be appreciated !
>
> Thanks in advance,
>
> Max
>
> On 20 aug, 10:48, Marcin Domanski aka kabturek <[EMAIL PROTECTED]>
> wrote:
>
> > have you created the model ?
>
> > On Aug 19, 5:04 pm, doekie <[EMAIL PROTECTED]> wrote:
>
> > > In the OCPHP sheets (http://www.cakephp.org/files/OCPHP.pdf) there was
> > > an example of the use of the new "With" Associations in a HABTM. So it
> > > must be easy to get values out-of the join-table in CakePHP 1.2
>
> > > var $hasAndBelongsToMany = array('Tag'=>
> > >                                               
> > > array('className'=>'Tag','with'=>'TaggedPost'));
>
> > > But i still getting errors like: No class found for the TaggedPost
> > > model...
> > > (The HABTM works without with (join-table-name: posts_tags))
>
> > > Has somebody an example/explanation how it works?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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