Re: [Maypole] Re: Maypole responding to requests very slowly (or, how to get just one associated record instead of getting the world)

From: Peter Speltz (peterspeltz at yahoo.com)
Date: Fri Dec 03 2004 - 14:23:36 GMT


--- Brian Glass <brian at glassbrian.com> wrote:

> Peter Speltz wrote:
>
> >It, putting this in _to_select, is desireable but It is tricky because the
> text
> >for the option is the stringify of the object so you need the object to get
> >that EXCEPT if this is set via "columns(Stringify" I believe. So, it seems
> >there has to be a little more communication between AsForm and the model
> class
> >to let _to_select know do this the efficient way ONLY IF the stringify value
> is
> >set via a sub. Does this sound about right?
> >
> >My idea is to make a sql_select_box_data via set_sql that would return id
> and
> >columns you want in string to appear in the select box.
> >
> >Then
> > if (@select_box_cols = $class->select_box_cols ||
> $class->columns('Stringify')
> >) {
> > # Do it efficient way, no object creation
> > my $sth = $class->sql_select_box_data;
> > # Someone fill in here
> >}
> >
> >else {
> > # current inefficient way
> >}
> >
> >
> >
> If sub stringify_self is defined then we CANNOT do this the efficient
> way. stringify_self needs to be called for each row/object and will
> probably proceed to go out and do more SQL queries. Only if the
> stringifying is done via __PACKAGE__->columns( Stringify => /foobar/ )
> should we do things the efficient way.
>

Exactly. I thought about it more last night. I going to write a stringify self
to accept an arrayref, hashref, or object. Then have _to_select do it the
efficient way every time.

I have a need for sometimes limiting the rows used in a select box , like on
category. I'm trying to figure this out. Ideally, an object would have a
"sql_select_box_data" sub. I'd like other_classes to be able to override that
by making there own statement. Example

Employee object with a type. You want to assign an engiineer to a Job
Default Employee->sql_select_box_data would be "Select __ESSENTIAL__ from
Employee". It would be awesome in my Job class to be able to simply override
that with an new sql statement -- "Select __ESSENTIAL from Employee where type
= 'Engineer'". Haven't figured out how to do this yet.

> OTOH, I am using both methods in my class and the select boxes are
> generated using Stringify and most other things via stringify_self.
>
> If I'm not mistaken set_sql does object creation. I think this is what
> we're trying to avoid in this case so it would probably be better to go
> with straight DBI.
>

You are mistaken. sql_* calls return a statement handle. you then execute it.
You're thinking of the add_constructor.
> _______________________________________________
> maypole mailing list
> maypole at lists.netthink.co.uk
> http://lists.netthink.co.uk/listinfo/maypole
>

=====
pjs

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT