[Rt-devel] [Searchbuilder] how to access fields from both joined tables in a SearchBuilder object

Mathieu Lafage mathieu.lafage at anevia.com
Mon Oct 4 11:33:57 EDT 2010

Dear all,

I believe I reached the correct place for a question about 
otherwise please forgive my noise.

I read the module documentation, the "RT Essential" book, I crawled this ML
archives, as well as google, and I gave a look at RT source code, 
however I admit
I did not dive very deep in Tickets.pm generic query code, but I did not 
a clear answer to this question :

   Can you access fields from both joined tables in your result set
   when you join two tables with Searchbuilder ?

 From my understanding and tests, this is not possible, or not obviously.
You SearchBuilder-derived class is connected to one table (through
$self->Table('mytable'); ) and you thus return records of a 
type linked to this base table.

Should I :
- forget using SearchBuilder for this purpose, it can not do it. period,
- create a proper view in my database, and create a SearchBuilder object 
   thus working around the SearchBuilder "limitation" described here,
- go back to "Modeling 101" and learn why what I want to do is bad. 
Please, teach me.
- use the splendid solution you will certainly describe here. :)

NB: I thought about the two following solutions, but I want to know if 
there is
a better (more general) way :
1) I may define my tables so I don't need to perform a Join in the first 
place to
get related informations, but I'm afraid normalization might suffer 
outrages here.
2) Alternately, I may access my two tables separately (with a 
SearchBuilder object
each) and "join" in the perl code, but I'm afraid I will call this a kludge.

Best regards,

More information about the rt-devel mailing list