Name

query — run SQL query

ATTRIBUTES

Attribute Pos. Req. Default Description
sql Yes Yes SQL statement
prefix sql
more No enable paginating with [more_list]
ml 50 number of items to display
more_template template for [more_list]
form form parameters embedded into more links
more_routine custom routine for [more_list]
table
failure text to return if query fails
query
wantarray
interpolate     0 interpolate input?
reparse     1 interpolate output?
hide     0 Hide the tag return value?

DESCRIPTION

BEHAVIOR

This tag does not appear to be affected by, or affect, the rest of Interchange.

EXAMPLES

Example: Ad-hoc table display

[query sql="select * from products" type=html /]

NOTES

AVAILABILITY

query is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: code/SystemTag/query.coretag
Lines: 16


# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: query.coretag,v 1.4 2007-03-30 23:40:49 pajamian Exp $

UserTag query               Order        sql
UserTag query               addAttr
UserTag query               attrAlias    base table
UserTag query               hasEndTag
UserTag query               PosNumber    1
UserTag query               Version      $Revision: 1.4 $
UserTag query               MapRoutine   Vend::Interpolate::query

Source: lib/Vend/Interpolate.pm
Lines: 4576

sub query {
if(ref $_[0]) {
  unshift @_, '';
}
my ($query, $opt, $text) = @_;
$opt = {} if ! $opt;
$opt->{prefix} = 'sql' unless $opt->{prefix};
if($opt->{more} and $Vend::More_in_progress) {
  undef $Vend::More_in_progress;
  return region($opt, $text);
}
$opt->{table} = $Vend::Cfg->{ProductFiles}[0]
  unless $opt->{table};
my $db = $Vend::Database{$opt->{table}} ;
return $opt->{failure} if ! $db;

$opt->{query} = $query
  if $query;

$opt->{query} =~ s:
    \[\Q$opt->{prefix}\E[_-]quote\](.*?)\[/\Q$opt->{prefix}\E[_-]quote\]
  :
    $db->quote($1)
  :xisge;

if (! $opt->{wantarray} and ! defined $MVSAFE::Safe) {
  my $result = $db->query($opt, $text);
  return (ref $result) ? '' : $result;
}
$db->query($opt, $text);
}

AUTHORS

Interchange Development Group

SEE ALSO

dbi_quote(7ic)

DocBook! Interchange!