On 07/09/10 14:47, M wrote:
> I'm sorry to bother you with this, but I'm having some trouble with what
> was a working template. The server version is running fine on TT 2.20 and
> Template-DBI-2.65 (I think)
> but when installed on my netbook with Template-Toolkit-2.22 and
> Template-DBI-2.64 things go wrong.
>
> The bit of template that seems to be failing looks like this.
> [% INCLUDE header.tmpl %]
> <a href="/ssnewform.pl" target="_blank"> New</a>
> [% USE DBI( database = 'dbi:mysql:solsystest',
> username = 'solsys' ,
> password = 'w0kk4' )
> %]
> <snip>
> [% sql %]
> [% main = DBI.prepare(sql) %]
Without seeing your sql statement and the real set bound params ...
> [% bind = [] %]
> [% FOREACH actives = active %]
> [% IF like.grep(actives).0 %]
> [% likact = parms.$actives %]
> [% bind.push("\%$likact\%") %]
> [% ELSE %]
> [% IF parms.$actives == 'ACTIVE' %]
> [% bind.push('quote') %]
> [% bind.push('first') %]
> [% bind.push('happen') %]
> [% ELSE %]
> [% bind.push(parms.$actives) %]
> [% END %]
> [% END %]
> [% END %]
> Bind: '[% bind.0 %]' j '[% bind.1 %]'
> [% FOREACH customer = main.execute(bind) %]
>
> <snip>
>
> the [% sql %] line and "Bind: '[% bind.0 %]' j '[% bind.1 %]'" are
> debugging and can be safely ignored.
>
> Now when the active array passed through from the perl script is empty
> this fails with
>
> DBI error - execute failed: called with 1 bind variables when 0 are needed
... I think it's a user error.
> If there's one item in the active array then it doesn't fail, but also
> doesn't seem to be passing anything meaningful through to the mysql server
> as nothing gets returned (my suspicion is it passes an array ref)
>
> If active holds 2 or more you get
>
> DBI error - execute failed: called with 1 bind variables when n are needed
>
> where n is the number passed.
I took maintainership for Template-DBI and working on an update (based
on DBI-1.612, so will not be uploaded before). I add some tests with bind
variables and check your reported issue. When I find out something, I let
you know.
Would you be available to do some tests with the trunk (development)
version, when I have a potential fix?
> Thus it seems to me that rather than passing a list of vars with the
>
> [% FOREACH customer = main.execute(bind) %]
>
> I'm passing one, which as I said above I assume is a ref to the array.
>
> So how do I deref this array, and why do I now need to.
Best regards,
Jens
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates