Problem with has_many and searching

[prev] [thread] [next] [Date index for 2004/10/05]

From: John Day
Subject: Problem with has_many and searching
Date: 16:06 on 05 Oct 2004
Using Class::DBI 0.96, Class::DBI::mysql  ..........
I have a pair of simple tables declared like this in my Class::DBI module:

package InContact::cDBI::contact;
use base 'InContact::cDBI';

__PACKAGE__->set_up_table('contact');
__PACKAGE__->has_many('contact_detail' => 'InContact::cDBI::contactdetail', 
'contact_id');

package InContact::cDBI::contactdetail;
use base 'InContact::cDBI';

__PACKAGE__->set_up_table('contactdetail');
__PACKAGE__->has_a('contact_id' => 'InContact::cDBI::contact');

What I want is an iterator pointing to all records in 
InContact::cDBI::contact which have a matching 
InContact::cDBI::contactdetail where the value of the recontact field is 
the selected date - $tm. So I execute this code:

     my $details = InContact::cDBI::contact->contact_detail(recontact => $tm);
     print Dumper $details;


What I get is:

2004/10/05
Tk::Error: Can't select for InContact::cDBI::contactdetail using 'SELECT
FROM   contact contact, contactdetail contactdetail
WHERE  contactdetail.contact_id = contact.id AND recontact = ?
' (SearchSQL): DBD::mysql::st execute failed: You have an error in your SQL 
syntax.  Check the manual that corresponds to your MySQL
  server version for the right syntax to use near 'FROM   contact contact, 
contactdetail contactdetail
WHERE  cont [for Statement "SELECT
FROM   contact contact, contactdetail contactdetail
WHERE  contactdetail.contact_id = contact.id AND recontact = ?
"] at D:/Perl/site/lib/DBIx/ContextualFetch.pm line 51.


(message missing)

Ima::DBI and connections at Apache startup
Brad Bowman 08:03 on 04 Oct 2004

Re: Ima::DBI and connections at Apache startup
Perrin Harkins 17:15 on 04 Oct 2004

Re: Ima::DBI and connections at Apache startup
Brad Bowman 01:15 on 05 Oct 2004

Re: Ima::DBI and connections at Apache startup
Brad Bowman 04:47 on 05 Oct 2004

Re: Ima::DBI and connections at Apache startup
Perrin Harkins 14:27 on 05 Oct 2004

Problem with has_many and searching
John Day 16:06 on 05 Oct 2004

Re: Ima::DBI and connections at Apache startup
Perrin Harkins 14:26 on 05 Oct 2004

Re: Ima::DBI and connections at Apache startup
Brad Bowman 05:01 on 06 Oct 2004

Re: Ima::DBI and connections at Apache startup
Perrin Harkins 15:23 on 06 Oct 2004

Re: Problem with has_many and searching
Perrin Harkins 16:21 on 05 Oct 2004

Re: Problem with has_many and searching
John Day 17:26 on 05 Oct 2004

Re: Ima::DBI and connections at Apache startup
Tony Bowden 17:31 on 06 Oct 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52