Hi there again,
I'm getting an error out of my code, and I don't really understand why I'm getting it, or what to do about it!
I'm using Class::DBI::Relationship::IsA to allow myself to subclass Users of my system. The Users package is as follows:
#!/usr/bin/perl
package MyDB::Users;
use base 'MyDB::DBI';
MyDB::Users->table('USERS');
MyDB::Users->columns(
All => qw/USERNAME PASS USERTYPE EMAIL/);
MyDB::Users->might_have(
CANDIDATE => 'MyDB::Candidates' => qw/FIRSTNAME LASTNAME DISABLED
+CV/);
MyDB::Users->might_have(
CLIENT => 'MyDB::Clients' => qw/NAME MAXROLES MAXCOMPETENCIES/);
1;
A User can be either a Client or a Candidate:
#!/usr/bin/perl
package MyDB::Candidates;
use base 'MyDB::DBI';
use MyDB::Users;
MyDB::Candidates->table('CANDIDATES');
MyDB::Candidates->columns( All =>
qw/USERNAME FIRSTNAME LASTNAME DISABLED/
);
MyDB::Candidates->is_a( USERNAME => 'MyDB::Users' );
1;
and
#!/usr/bin/perl
package MyDB::Clients;
use base 'MyDB::DBI';
use MyDB::Users;
MyDB::Clients->table('CLIENTS');
MyDB::Clients->columns(
All => qw/USERNAME NAME MAXROLES MAXCOMPETENCIES/);
MyDB::Clients->is_a( USERNAME => 'MyDB::Users');
1;
Anyway...
The problem comes when in the code for the app itself I call
my @objs = MyDB::Clients->retrieve_all();
At which point I get the error:
Can't locate object method "username" via package "ctmclient" (perhaps you forgot to load "ctmclient"?) at Class/DBI/Relationship/IsA.pm line 311.
(ctmclient is the username of the one client which I have inserted into the database - it is in the Clients and Users tables correctly). Anyway, can anyone point me towards where I might be going wrong. The docs for IsA seem to be a bit sketchy at best.
Thanks in advance.
Mel
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.