Objects tree with Class::DBI

[prev] [thread] [next] [Date index for 2005/05/13]

From: subscribes
Subject: Objects tree with Class::DBI
Date: 03:38 on 13 May 2005
Sorry for my previous post.

I have object definition:

package PXF::M::Section;
use strict;
use lib qw[./../../];
use base 'PXF::M::DBI';

__PACKAGE__->table('pxf_section');
__PACKAGE__->columns(Primary => qw[id]);
__PACKAGE__->columns(Essential => qw[path parent name]);
__PACKAGE__->has_a(parent => 'PXF::M::Section');
__PACKAGE__->has_many(children => ['PXF::M::Section' => 'parent']);

1;

and data in tables

id  parent  path   name  
5   0       test   Section 
6   5       test2  Section 2 

After call
my @sections = PXF::M::Section->retrieve_all();
I expect something like that
[{
  id => 5,
  parent => undef,
  path => 'test',
  name => 'Section',
  children => [{
    id => 6,
    parent => {
      id => 5,
      parent => undef,
      path => 'test',
      name => 'Section'
    },
    path => 'test',
    name => 'Section'
  }]
},
{
  id => 6,
  parent => {
    id => 5,
    parent => undef,
    path => 'test',
    name => 'Section'
  },
  path => 'test',
  name => 'Section'
  children => []
}
]

but I retrieve following list (printed with Data::Dump)
do {
  my $a = bless({
    id => 5,
    name => "Section",
    parent => bless({ id => 0 }, "PXF::M::Section"),
    path => "test",
  }, "PXF::M::Section");
  (
    $a,
    bless({ id => 6, name => "Section 2", parent => $a, path => "test2" }, "PXF::M::Section"),
  );
}
where is the children?
thanks for advise.

(message missing)

Objects tree with Class::DBI
subscribes 19:57 on 12 May 2005

Re: Objects tree with Class::DBI
Perrin Harkins 20:31 on 12 May 2005

Re: Objects tree with Class::DBI
Christopher Hicks 21:14 on 12 May 2005

Re: Objects tree with Class::DBI
Jay Strauss 21:22 on 12 May 2005

Objects tree with Class::DBI
subscribes 03:38 on 13 May 2005

Re: Objects tree with Class::DBI
Michael Peters 12:03 on 13 May 2005

Generated at 16:36 on 28 Jul 2005 by mariachi v0.52