First Attempt

[prev] [thread] [next] [Date index for 2005/01/28]

From: cpryce
Subject: First Attempt
Date: 20:29 on 28 Jan 2005
I'm trying to wrap my head around Class::DBI. I have the following simple database 
to store a resume. Each resume can have one or more areas of experise. 

When I run the following script, I ger the error message:

resume is not a column of MyDBI::Resume::Exper at /Library/Perl/5.8.1/Class/DBI/Relationship/HasMany.pm line 118

#!/usr/bin/perl 

use strict;
use MyDBI::Resume;

my ($r) = MyDBI::Resume->search( rid => 1 );

foreach my $exp ( $r->expertise ) {
    print $exp->exp, "\n";
}


package MyDBI::Resume::DBI;
use base 'Class::DBI::mysql';

__PACKAGE__->connection('dbi:mysql:resume;host=localhost', 'u/n', 'p/w');

1;

package MyDBI::Resume;
use base 'MyDBI::Resume::DBI';

__PACKAGE__->set_up_table('tblresume');

__PACKAGE__->has_many( 'expertise'  => 'MyDBI::Resume::Exper' );
__PACKAGE__->has_many( 'education'  => 'MyDBI::Resume::Edu' );

1;

package MyDBI::Resume::Exper;
use base 'MyDBI::Resume::DBI';

__PACKAGE__->set_up_table( 'tblexpertise' );

1;



The Database contains; 

> Select * from tblresume
+-----+-------------+----------+--------+-------+---------------+
| rid | firstname   | lastname | suffix | empid | title         | 
+-----+-------------+----------+--------+-------+---------------+
|   1 | Christopher | Pryce    |        |   278 | Web Developer |

....

> Select * from tblexpertise
+-----+-----+----------------------------------+
| xid | rid | exp                              |
+-----+-----+----------------------------------+
|   1 |   1 | Graphic Design                   |
|   2 |   1 | Web Development                  |

Created with: 

       Create Table tblresume (
            rid         MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
            firstname   VARCHAR(50), 
            lastname    VARCHAR(50),
            suffix      VARCHAR(18),
            empid       MEDIUMINT UNSIGNED,
            title       VARCHAR(50),
            years_xp    SMALLINT UNSIGNED,
            years_srf   SMALLINT UNSIGNED,
            rdesc       TEXT,
            KEY ( lastname, firstname )
      );
      Create Table tblexpertise ( 
            xid         MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
            rid         MEDIUMINT UNSIGNED NOT NULL, 
            exp         VARCHAR(50),
            KEY ( exp )
       );

First Attempt
cpryce 20:29 on 28 Jan 2005

Re: First Attempt
Peter Speltz 20:58 on 28 Jan 2005

Re: First Attempt
Drew Taylor 14:44 on 29 Jan 2005

Re: First Attempt
Christopher Pryce 15:26 on 29 Jan 2005

Generated at 12:39 on 05 Feb 2005 by mariachi v0.52