PREFIX-param
Summary
Description
Returns the value of the column name associated with the
looping tag's current row.
Each looping list returns an array of return fields,
set in searches with
mv_return_fields.
The default is only to return the code of the search result,
but by setting those parameters you can return whichever columns you like.
In a [query] tag you can select multiple return
columns with something like:
[query prefix=prefix sql=|
SELECT foo, bar
FROM baz
WHERE foo = 'baz'
|]
[prefix-code], [prefix-param foo], [prefix-param bar]<br>
[/query]
|
In this case,
[PREFIX-code] and [PREFIX-param foo]
are synonyms,
as foo is the first returned column and becomes the code for this row.
Another synonym is [PREFIX-pos 0].
Mixed case field names in your SQL tables will be forced to lower
case in the [PREFIX-param name] tag,
if the underlying Database does that (most SQL databases do).
For example if your query is
[query prefix=prefix sql=|
SELECT Foo, Bar
FROM baz
WHERE Foo = 'buz'
|]
|
then you must use:
|
[prefix-param foo] and [prefix-param bar]
|
to display your results, rather than:
|
[prefix-param Foo] and [prefix-param Bar]
|
Note that the following code is invalid:
[query prefix=prefix sql=|
SELECT table1.foo,
table2.bar
FROM table1, table2
WHERE table1.code = table2.code
AND table1.foo = 'baz'
|]
[prefix-param table1.foo], [prefix-param table2.bar]<br>
[/query]
|
The problem with the above code is that the Perl DBI doesn't support
column names such as table1.foo in its resultsets.
The following query syntax is fully supported by DBI,
and therefore by Interchange:
[query prefix=prefix sql=|
SELECT table1.foo AS foo,
table2.bar AS bar
FROM table1, table2
WHERE table1.code = table2.code
AND table1.foo = 'baz'
|]
[prefix-param foo], [prefix-param bar]<br>
[/query]
|
See also