Top of the model is :

class MenuItem extends AppModel
{
        var $name = 'MenuItem';

        var $actsAs = array('Tree', 'Containable');


the table :

CREATE TABLE `menu_items` (
  `id` int(11) NOT NULL auto_increment,
  `parent_id` int(11) default NULL,
  `lft` int(11)  default NULL,
  `rght` int(11)  default NULL,
  `label` varchar(255) NOT NULL,
  `url` varchar(255) NOT NULL,
  `online` int(1) NOT NULL,
  `order` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;



Are you suggesting that I should add a belongTo to this model?
(belongsTo itself?)


On 3 déc, 01:02, Dave <davidcr...@gmail.com> wrote:
> Also, these two suggestions were in the comments.  I didn't need the
> relationship from the first one but I am using the latest svn checkout, so
> perhaps he was posting that from an older version.  Also the second one
> might be useful as well.
>
>  The model needs a relation for me to work with this example.
>
> If I add the following to the model it works:
>
> <pre>
>
> var $belongsTo = array(
>
> 'Parent' =&gt; array(
>
> 'className' =&gt; 'Category',
>
> 'foreignKey' =&gt; 'parent_id',
>
> 'conditions' =&gt; '',
>
> 'fields' =&gt; '',
>
> 'order' =&gt; '',
>
> 'counterCache' =&gt; ''),
>
> );
>
> </pre>
>
> By etipaced on 30/9/08
>
> 2 <#comment_391> - bug/glitch/feature?
>
> I just spent a lot of time troubleshooting an odd issue. Make sure your id,
> lft and rght columns are set to just UNSIGNED and not UNSIGNED ZEROFILL. I
> like to use the ZEROFILL attribute on all my integer column types that store
> id values but the TreeBehavior fails without any warnings or errors if the
> integer column values are in the format of 00000001 instead of just 1.
>
> On Wed, Dec 2, 2009 at 7:00 PM, Dave <davidcr...@gmail.com> wrote:
> > Can you paste your model?  Or at least the important parts at the top?
>
> > On Wed, Dec 2, 2009 at 6:19 PM, Martin Kirchgessner <
> > martin.ki...@gmail.com> wrote:
>
> >> Hi everyone,
>
> >> I'm using TreeBehavior in a classic model, but its lft and rght fields
> >> are not set correctly.
>
> >> I tried these two save() in a controller  :
>
> >>                $this->MenuItem->create();
> >>                $this->MenuItem->save(array('MenuItem' => array(
> >>                        'url' => '/fre',
> >>                        'parent_id' => null,
> >>                        'label' => 'Home',
> >>                        'online' => 1
> >>                        )));
> >>                $parent_id = $this->MenuItem->id;
> >>                debug($this->MenuItem->verify());
>
> >>                $this->MenuItem->create();
> >>                $this->MenuItem->save(array('MenuItem' => array(
> >>                        'url' => '/fre/p/Choses',
> >>                        'parent_id' => $parent_id,
> >>                        'label' => 'Choses',
> >>                        'online' => 1
> >>                        )));
>
> >>                debug($this->MenuItem->verify());
>
> >>                debug($this->MenuItem->recover());
>
> >>                debug($this->MenuItem->verify());
>
> >>                die();
>
> >> I truncated the table menu_items, ran the test and discovered that the
> >> two last calls to verify() fail, even after recover().
>
> >> I followed the cookbook... but did I miss something?
>
> >> If it can helps :
> >> I'm running Cake 1.2.3.8166
> >> I also tried to download the last TreeBehavior from cake's master
> >> branch, but it didn't change anything
>
> >> 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 cake-php@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
> >>  more options, visit this group at
> >>http://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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to