[Dbix-class] I get only one in a one to one

Miguel Barco miguelelelele at yahoo.es
Mon Jan 9 21:09:40 GMT 2012


Thank you,=A0I never would have noticed that the html comments does not aff=
ect to the TT/Catlayst logic.


But the problem remains the same, because I want to retrieve some columns f=
rom the main table an some from the related one, so I was told to use Prefe=
tch.

What I really need is something as simple as this query (that I can use eve=
rywhere):

SELECT=A0books.title,=A0contents.content_en
FROM=A0books,=A0contents
WHERE=A0books.id=A0=3D=A01111
AND=A0contents.id=A0=3D=A01111

I am be very surprised that I am stuck with it!!


Regards:
Migue



________________________________
De:=A0Jorge Gonzalez <jorge.gonzalez at daikon.es>
Para:=A0dbix-class at lists.scsys.co.uk=A0
Enviado:=A0lunes 9 de enero de 2012 10:49
Asunto:=A0Re: [Dbix-class] I get only one in a one to one


You have commented out the line where you get content_en from the CONTENTS =
table, but you have done so _in HTML_. The template engine is running your =
template, including your HTML comment, and is getting the content_en field,=
 just to put it in an HTML comment.

If you want to avoid the TT engine calling the relationship you must commen=
t the call _inside_ the TT code, i.e.:

(...)

[% FOREACH book IN books -%]
=A0 <tr>
<td>[% book.title %]</td>
=A0 =A0 =A0 =A0 <td>[% # book.the_content.content_en %]</td>

=A0 </tr>
[% END -%](...)

And something more: if you just want a column from a relation, do a join, n=
ot a prefetch:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120109/0b3=
2cf57/attachment.htm


More information about the DBIx-Class mailing list