Re: [CDBI] Re: coding a join
Michael Reece <[email protected]> Tue, 17 Apr 2007 09:12:12 -0700
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
i usually end up with something like
sub latest_contact_dt {
my $self = shift;
return $self->sql_latest_contact_dt->select_val($self->id);
}
On Apr 16, 2007, at 5:28 PM, Arshavir Grigorian wrote:
> Thanks. It worked.
>
> package Class::Contact;
>
> __PACKAGE__->set_sql( latest_contact_dt => 'select max(cm.create_dt)
>
> from communication cm, contact cn
>
> where cm.contact_id = cn.id
>
> and cn.id = ?');
> The way I call this is
>
> $contact->sql_latest_contact_dt($contact->id);
>
> Is there a more elegant way to code this so that the class knows to
> use the caller's id when running that sql?
>
>
>
>
> On 4/14/07, Edward J. Sabol <sabol-2oVx0MVsMgiP/[email protected]> wrote:
>> Arshavir Grigorian wrote:
>> > I think I need set_sql() but since Class::DBI expects the set_sql()
>> > query to return a primary key, I am not sure how to proceed.
>>
>> That's incorrect. Please re-read the documentation, specifically
>> these two
>> sections:
>>
>> http://search.cpan.org/~tmtm/Class-DBI/lib/Class/DBI.pm#Ima%3A%
>> 3ADBI_queries
>> http://search.cpan.org/~tmtm/Class-DBI/lib/Class/
>> DBI.pm#Single_Value_SELECTs
>>
>> Hope this helps,
>> Ed
>>
>
> _______________________________________________
> ClassDBI mailing list
> ClassDBI-Ra3b/[email protected]
> http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
---
michael reece :: software engineer :: [email protected]