[CDBI] Re: coding a join

Arshavir Grigorian grigorian at gmail.com
Tue Apr 17 01:28:34 BST 2007

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


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 at alderaan.gsfc.nasa.gov> 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

More information about the ClassDBI mailing list