Re: [Templates] MySQL problem continued

[prev] [thread] [next] [Date index for 2005/01/21]

From: Shanta McBain
Subject: Re: [Templates] MySQL problem continued
Date: 17:26 on 21 Jan 2005
On Thursday 20 January 2005 02:39 am, Simon Matthews wrote:
> The problem is that you are not naming your DBI queries and the content of
> the DBI object is getting mangled by you calling it again.
>
> There are two solutions to this:
>
> 1. Create more than one DBI object like so....
>
>
> [% USE q1 = DBI(.....) %]
> [% USE q2 = DBI(.....) %]
>
> Which is my preferred approach because some DBI connections do not allow
> you to have more than one result set open at any one time.
>
> More on this in:
> http://www.template-toolkit.org/docs/plain/Modules/Template/Plugin/DBI.html
> look for Using Named DBI connections.

 Thanks. This one works. 

> 2. As you are using mysql you can actually get away with having more than
> one result set open so you can do something like this:
>
> [% USE DBI(....) %]
> [% results1 = DBI.query("the sql for your outer query") %]
>
> [% FOREACH result = results %]
> 	[% FOREACH inner = DBI.query("your inner sql") %]
>
> 	[% END %]
> [% END %]
>
>
If I am reading this right I am populating a result set into results1  Then 
using them in a different set of conditional statements that only contain one  
quire.

Should the first [% FOREACH result = results %] read [% FOREACH result = 
results1 %]
 
> You can find examples of this in t/dbi.t in the Template Toolkit
> distribution

I will find them and have a look.


        -- 
        Thanks
Shanta McBain
Http://computersystemconsulting.ca Web hosting and Application Hosting.

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] MySQL problem continued
Shanta McBain 19:33 on 19 Jan 2005

RE: [Templates] MySQL problem continued
Simon Matthews 10:39 on 20 Jan 2005

Re: [Templates] MySQL problem continued
Shanta McBain 17:26 on 21 Jan 2005

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52