Hey everyone.
Thanks again for help on that mysql_use_result and the iterator. In
hindsight it wasn't really even a Rose::DB issue, so I really
appreciate that you guys took time out to help me. I've come up with
a good way to only use that client variable when I need it, and I am
able to iterate over the entire huge table when I need to.
I do have another question, which is most certainly Rose::DB related. :)
Consider the following 3 tables:
db.a:
+-------+-----------------------+------+-----+---------+
| Field | Type | Null | Key | Default |
+-------+-----------------------+------+-----+---------+
| id | mediumint(8) unsigned | NO | PRI | NULL |
| b_id | mediumint(1) | NO | | 1 |
| data | text | YES | | NULL |
+-------+-----------------------+------+-----+---------+
db.b:
+-------+-----------------------+------+-----+---------+
| Field | Type | Null | Key | Default |
+-------+-----------------------+------+-----+---------+
| id | mediumint(8) unsigned | NO | PRI | NULL |
| c_id | mediumint(1) | NO | | 1 |
| data | text | YES | | NULL |
+-------+-----------------------+------+-----+---------+
db.c:
+-------+-----------------------+------+-----+---------+
| Field | Type | Null | Key | Default |
+-------+-----------------------+------+-----+---------+
| id | mediumint(8) unsigned | NO | PRI | NULL |
| data | text | YES | | NULL |
+-------+-----------------------+------+-----+---------+
with b_id in db.a and c_id in db.b as foreign keys, except in a
myisam table, so not really foreign keys but 'relationships' in
rose::db parlance.
suppose also that there are Rose::DB::Object and ::Manager classes
setup for each of these, with the relationships described. So A.pm
would look like this:
package A;
...
__PACKAGE__->meta->setup(
table => 'a',
columns => [ qw(id b_id data) ]
pk_columns => 'id',
relationships =>
[
b =>
{
type => 'many to one',
class => 'B',
column_map => { b_id => 'id' },
},
],
);
and so on, such that A relates to C through B.
I want to call get_objects on A::Manager with constraints for C, but
I don't know how to setup that relationship in class A, or if it is
even possible. i.e. I want to be able to say
my $iterator = A::Manger->get_objects(
query => [
data => { regexp => 'blah' },
b.data => { regexp => 'blah2' },
c.data => { regexp => 'blah3' },
],
require_objects => [ 'b','c' ],
);
but A::Manager can't require object C because there is no
relationship setup for it. I tried (maybe naively) to add a
relationship to A:
c =>
{
type => 'many to one',
class => 'C',
column_map => ' b->c_id' => 'id',
}
which i'm sure you already know doesn't work.
any thoughts on how I can accomplish this?
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object