Re: [CDBI] Group by and AbstractSearch

[prev] [thread] [next] [Date index for 2005/10/21]

From: Michael Peters
Subject: Re: [CDBI] Group by and AbstractSearch
Date: 16:19 on 21 Oct 2005

Brett Sanger wrote:
> On Fri, Oct 21, 2005 at 07:48:00AM -0700, Bill Moseley wrote:
> 
>>>sub area_summary {
>>>  my $self = shift;
>>>  my $sql = SQL::Abstract->new();
>>>  my ($where, @bind) = $sql->where(@_);
>>>  return $self->sql_summarize($where)->select_val(@bind);
>>>}
>>
>>Doesn't select_val() return just one value?  Seem like in the case
>>above you would define a TEMP column 'Count' and then search as
>>normal with $class->search_summarize()
> 
> 
> After some more doc reading, delving into the code, and some
> experimentation:
> 
> search_summarize() wouldn't let me pass my arbitrary where clauses (it
> accepts data for placeholders, but not string replacement)
> 
> sql_summarize() let's me pass along arbitrary string replacments, but
> then I'm left with a statement handle. I can execute() it to fill my
> placeholders, but then I'm outside my CDBI model.

One of the nicest things about C::DBI (IMO) is that you can not only
step outside of C::DBI to use straight DBI/SQL, but that you can then
step back (in most cases).


> sub area_summary {
>   my $self = shift;
>   my $sql = SQL::Abstract->new();
>   my ($where, @bind) = $sql->where(@_);
>   return $self->sth_to_objects($self->sql_summarize($where), \@bind);
> }
> 
> But again, I'm a little uncomfortable since sth_to_objects() is undocumented
> (but not marked as internal)
> 
> Can someone provide me some info to say if this is the intended course or not?

Well, sth_to_objects() isn't documented by itself, but is is mentioned
in at least one example. I use it all the time, so I hope it's now
officially public :)

        -- 
        Michael Peters
Developer
Plus Three, LP


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

[CDBI] Group by and AbstractSearch
Brett Sanger 13:53 on 21 Oct 2005

Re: [CDBI] Group by and AbstractSearch
Bill Moseley 14:48 on 21 Oct 2005

Re: [CDBI] Group by and AbstractSearch
Brett Sanger 15:42 on 21 Oct 2005

Re: [CDBI] Group by and AbstractSearch
Dave Howorth 15:59 on 21 Oct 2005

Re: [CDBI] Group by and AbstractSearch
yoorobot 16:01 on 21 Oct 2005

Re: [CDBI] Group by and AbstractSearch
Brett Sanger 16:10 on 21 Oct 2005

Re: [CDBI] Group by and AbstractSearch
Michael Peters 16:19 on 21 Oct 2005

Re: [CDBI] Group by and AbstractSearch
Matt S Trout 16:34 on 21 Oct 2005

Re: [CDBI] Group by and AbstractSearch
Bill Moseley 18:20 on 21 Oct 2005

Generated at 19:52 on 24 Oct 2005 by mariachi v0.52