Gossamer Forum
Home : Products : DBMan SQL : Development, Plugins and Globals :

Globals syntax problem

Quote Reply
Globals syntax problem
What is the correct syntax to quote the resultant variable as described below

The Global:

colsel

sub {
require GT::SQL::Condition;
my $tags = GT::Template->tags;
my $requestor = $tags->{requestor};
my $cd = GT::SQL::Condition->new(['requestor','=',$requestor]);
my $results = $DB->table('avo13')->select($cd,['reqphone'])->fetchall_hashref;
return { loop_select => $results };
}

With the HTML:
<%colsel%>
<%loop loop_select%>
<%reqphone%>
<%endloop%>


Returns:
GT::SQL::error = Failed to execute query: 'SELECT reqphone FROM avo13 WHERE ( requestor = ALBRANT, PAUL )
' Reason: You have an error in your SQL syntax.

What is the syntax to have ...requestor = 'ALBRANT, PAUL' ... quoted in the above global

Quote Reply
Re: [billdgt] Globals syntax problem In reply to
Try this:

...
my $requestor = (ref $tags->{requestor} eq 'ARRAY') ? $tags->{requestor} : [$tags->{requestor}];
my $cd = GT::SQL::Condition->new(requestor => 'IN' => $requestor);
...

It should fix the bug.

TheStone.


B.
Quote Reply
Re: [TheStone] Globals syntax problem In reply to
I have replaced as you have indicated and get exactly the same error

The $requestor variable is not quoted which results in the SQL error
Quote Reply
Re: [billdgt] Globals syntax problem In reply to
Can you send me the admin info? I'll take a look at it.

TheStone.

B.