[Maypole] create with sql-function values

Simon Cozens simon@simon-cozens.org
Sun, 2 May 2004 09:32:41 +0100


forehead:
> 1. when I create the Class::DBI object , like this:
> user->create({
> 	username => $username,
> 	password => $password,
> 	create_on => 'now()'
> });
> 
> here the create_on column is a 'datetime' one , the the value 'now()' 
> will not give the object right stuff what I expected. 

Class::DBI problem.

> 2. the table data will map to perl class-object. sometimes i need the objects
> orgnized as a tree( the data struct), which has parents and children, and when
> delete one, it will delete the children. or other any data struct , any idea to
> implement that for more convient , write a abstract tree class or a Class::DBI:Plugin ?
> any good idea?

Class::DBI problem. However, if you've set up the relationships properly:

    MyThing::Node->has_a(parent   => "MyThing::Node");
    MyThing::Node->has_a(child    => "MyThing::Node");
    MyThing::Node->has_a(sibling  => "MyThing::Node");

you should be able to set up triggers to give you the appropriate cascading
delete:

    MyThing::Node->add_trigger(before_delete => sub {
        my $self = shift;
        $self->child && $self->child->delete;
        $self->sibling && $self->sibling->delete;
    });

> may the question more about the Class::DBI, but since maypole is
> almost use that modules features

Maypole uses Perl, but that doesn't mean this is the best place to ask generic
Perl questions... :)


-- 
I've looked at the listing, and it's right!
                -- Joel Halpern