Added to Category model:
var $belongsTo = array (
'Maincat' => array (
'className' => 'Maincat',
'foreignKey' => 'maincat_id'
)
);
Trying to set recursive to 1 and 2, but nope.
$this->Maincat->recursive = 1;
print_r($this->Maincat->findAll());
Result is same as before.
Any suggestions?
On 13 фев, 16:42, "Seb" <[EMAIL PROTECTED]> wrote:
> @alexxwiz : try adding this to your Category model;
> var $belongsTo = array ('Maincat');
>
> @shoesole : note how you don't have to use the className value if you
> stick to the naming convention, hence your
> var $belongsTo = array('Blog' => array('className' => 'Blog') );
> can become
> var $belongsTo = array('Blog');
>
> Hope that helps!
>
> Cheers,
>
> Seb.
>
> On Feb 13, 11:27 pm, "alexxwiz" <[EMAIL PROTECTED]> wrote:
>
> > I have same problem.
> > Two tables:
>
> > CREATE TABLE `maincats` (
> > `id` int(10) unsigned NOT NULL auto_increment,
> > `title` varchar(255) default NULL,
> > `visible` tinyint(4) NOT NULL default '1',
> > `created` datetime NOT NULL,
> > PRIMARY KEY (`id`)
> > ) ENGINE=MyISAM;
>
> > CREATE TABLE `categories` (
> > `id` int(10) unsigned NOT NULL auto_increment,
> > `title` varchar(255) default NULL,
> > `maincat_id` int(11) default NULL,
> > `visible` tinyint(4) NOT NULL default '1',
> > `created` datetime NOT NULL,
> > PRIMARY KEY (`id`)
> > ) ENGINE=MyISAM;
>
> > Two models:
>
> > class Maincat extends AppModel {
> > var $name = 'Maincat';
> > var $hasMany =
> > array('Category'=>array('className'=>'Category','foreignKey' =>
> > 'maincat_id'));
>
> > }
>
> > class Category extends AppModel {
> > var $name = 'Category';
>
> > }
>
> > print_r($this->Maincat->findAll());
>
> > returns only maincats content and none sub-categories.
>
> > Array
> > (
> > [0] => Array
> > (
> > [Maincat] => Array
> > (
> > [id] => 1
> > [title] => Some first
> > [visible] => 1
> > [created] => 2007-02-13 14:39:28
> > )
>
> > )
>
> > [1] => Array
> > (
> > [Maincat] => Array
> > (
> > [id] => 2
> > [title] => Some second
> > [visible] => 1
> > [created] => 2007-02-13 00:00:00
> > )
>
> > )
>
> > )
>
> > Where is my mistake?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---