Hi Adrian,

Thank you very much. I manganed to do so ;-)

Regards,
Apprentice.

On Nov 5, 1:02 am, "Adrian Godong" <[EMAIL PROTECTED]> wrote:
> You should change the name of the 'association'. E.g.:
>
> ...
>         var $belongsTo = array(
>                         'ParentCategory' =>
>                          array('className' => 'Category',
> ...
>
> And
>
> ...
>         var $hasMany = array(
>                         'ChildCategory' =>
>                          array('className' => 'Category',
> ...
>
> Good luck!
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
>
> Of Apprentice
> Sent: 04 Nopember 2006 19:54
> To: Cake PHP
> Subject: How to display Child categories of self-pointed Model?
>
> Hi all,
>
> I have a Model Category:
>
> ----------------------------------------
> <?php
> class Category extends AppModel
> {
>         var $name = 'Category';
>         var $validate = array(
>                 'name' => VALID_NOT_EMPTY,
>                 'description' => VALID_NOT_EMPTY,
>         );
>
>         //The Associations below have been created with all possible keys,
> those that are not needed can be removed
>         var $belongsTo = array(
>                         'Categories' =>
>                          array('className' => 'Category',
>                                         'conditions' => '',
>                                         'fields' => '',
>                                         'order' => 'Categories.ord ASC',
>                                         'foreignKey' => 'category_id',
>                                         'counterCache' => ''),
>
>         );
>
>         var $hasMany = array(
>                         'Categories' =>
>                          array('className' => 'Category',
>                                         'foreignKey' => 'category_id',
>                                         'conditions' => '',
>                                         'fields' => '',
>                                         'order' => 'Categories.ord ASC',
>                                         'limit' => '',
>                                         'offset' => '',
>                                         'dependent' => '',
>                                         'exclusive' => '',
>                                         'finderSql' => '',
>                                         'counterSql' => ''),
>
>                         'Post' =>
>                          array('className' => 'Post',
>                                         'foreignKey' => '',
>                                         'conditions' => '',
>                                         'fields' => '',
>                                         'order' => '',
>                                         'limit' => '',
>                                         'offset' => '',
>                                         'dependent' => '',
>                                         'exclusive' => '',
>                                         'finderSql' => '',
>                                         'counterSql' => ''),
>
>         );
>
> }
> ?>
> ----------------------------------------
>
> And the table that serves Category:
> ----------------------------------------
> CREATE TABLE `categories` (
>   `id` int(10) NOT NULL auto_increment,
>   `category_id` int(10) NOT NULL default '0',
>   `name` varchar(50) collate utf8_bin NOT NULL,
>   `description` varchar(255) collate utf8_bin NOT NULL,
>   `created` datetime NOT NULL,
>   `modified` datetime NOT NULL,
>   PRIMARY KEY  (`id`),
>   KEY `category_id` (`category_id`,`name`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin
> COMMENT='Categories' AUTO_INCREMENT=8 ;
> ----------------------------------------
> By doing:
>
> $this('categories', $this->Category->findAll())
>
> I can only display the Parent Category, which is containted in the
> array $categories['Categories']
>
> I don't know how to find, retrieve & display Child Categories. Please
> give a hint.
> 
> Any help is appreciated. Thank you in advance!
> 
> Apprentice.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" 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