[Dbix-class] Multi-table search - how to?

RA Jones ra.jones at dpw.clara.co.uk
Tue May 8 13:35:56 GMT 2007


Hi folks,

I have a large application with many db tables (nothing unusual there). 
One of the requirements is to retrieve data across multiple tables. As 
there is no obvious 'main' table to base the query on, I tried to create 
a new schema (GetAll) not based on any table, along the lines described 
in a patch to the DBIC Manual Cookbook (Arbitrary SQL through a custom 
ResultSource - http://dev.catalyst.perl.org/trac/bast/changeset/3263). 
It failed: Couldn't instantiate component "MyApp::Model::Schema", 
"Cannot load schema class 'Schema': DBIx::Class::Schema::load_classes(): 
Can't locate object method "result_source_instance" via package 
"Schema::GetAll" at line .... etc.

I haven't shown my code as I don't think this is the right way to go 
about it. Basically I want the DBIC equivalent of:

select var1, var2, var3, var101, etc
from table1 a
   left join table2 b on a.id = b.id
   left join table3 c on a.id = c.id
   etc
where a.var1 = 'foo' and c.var10 = 'bar'

It's probably easier than I imagine....
--
Richard Jones
Leeds, UK

**********************************************************************
This message  may  contain  confidential  and  privileged information.
If you are not  the intended  recipient please  accept our  apologies.
Please do not disclose, copy or distribute  information in this e-mail
or take any  action in reliance on its  contents: to do so is strictly
prohibited and may be unlawful. Please inform us that this message has
gone  astray  before  deleting it.  Thank  you for  your co-operation.

NHSmail is used daily by over 100,000 staff in the NHS. Over a million
messages  are sent every day by the system.  To find  out why more and
more NHS personnel are  switching to  this NHS  Connecting  for Health
system please visit www.connectingforhealth.nhs.uk/nhsmail
**********************************************************************




More information about the Dbix-class mailing list