Name

db-hash —

ATTRIBUTES

Attribute Pos. Req. Default Description
table Yes
column Yes
key Yes
value
show_error
keys
joiner
interpolate     0 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

No examples are available at this time. We do consider this a problem and will try to supply some.

NOTES

AVAILABILITY

db-hash is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: code/UI_Tag/db_hash.coretag
Lines: 62


# 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: db_hash.coretag,v 1.5 2007-03-30 23:40:54 pajamian Exp $

UserTag db-hash Order      table column key
UserTag db-hash PosNumber  3
UserTag db-hash addAttr
UserTag db-hash Version    $Revision: 1.5 $
UserTag db-hash Routine    <<EOR
sub {
my($table, $col, $key, $opt) = @_;
$col =~ s/:+(.*)//s;
my $out;
my $rest = $1;
my $val = ::tag_data($table,$col,$key);

my $ref;
if ($val !~ /\S/) {
  $ref = {};
}
else {
  $ref = $Vend::Interpolate::ready_safe->reval($val);
  if (! ref $ref) {
    $ref = {};
  }
}
if (! $rest) {
  return $val unless defined $opt->{value};
}
my @extra;
@extra = split /:+/, $rest;
my $final = pop @extra;
my $curr = $ref;
$out .= "Original key request: $rest\n";
$out .= "\nFinal key: $final\n";
for(@extra) {
  $out .= "key --> $_\n";
  $curr = $curr->{$_};
  if (! ref $curr) {
    return "BAD HASH: $out" if $opt->{show_error};
    return;
  }
}

if($opt->{keys}) {
  return join get_joiner($opt->{joiner}), sort keys %$curr;
}
elsif(! defined $opt->{value}) {
  return $curr->{$final};
}
else {
  $curr->{$final} = $opt->{value};
  tag_data($table, $col, $key, { value => uneval_it($ref) });
  return $curr->{$final};
}
}
EOR

AUTHORS

Interchange Development Group

SEE ALSO

DocBook! Interchange!