[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
Re: [ic] Problem with using %Db in local usertags (4.7.x)
On Thu, Apr 19, 2001 at 07:44:08PM +0200, Stefan Hornburg (Racke) wrote:
>
> Hello,
>
> I'm having a usertag like this:
>
> UserTag example Routine <<EOF
> sub {
> $db = $Db{'whatever'};
> unless ($db) {
> Log ("No such database: %s", 'whatever');
> return;
> }
> }
> EOF
>
> If I call [example] on a page, I get an error "No such database".
> The error can be avoided by placing [perl tables=whatever]
> anywhere before [example]. This seems rather clumsy to me.
>
> The database in question is SQL.
>
> Any hints to improve this ?
>
This is how I was able to get a database handle in a usertag:
UserTag example Routine <<EOF
sub {
#I hacked this out by reading in the Interchange perl modules
my $db = Vend::Data::database_exists_ref('database_name');
unless ($db) { #I am guessing you could put this here.
Log ("No such database: %s", 'whatever');
return;
}
my %Sql = ();
$Sql{'database_name'} = $db->[$Vend::Table::DBI::DBI];
#now I have a database handle $dbh
my $dbh = $Sql{'database_name'};
#can create a statement handle, and it acts normally
my $sth = $dbh->prepare("select * from database_name");
$sth->execute();
$sth->finish();
}
EOF
now, there could be an easier way to do this and I was just doing it the hard
way. I would be interested in easier ways of doing this myself.
Dave Totten
--
Start random buzzword text:
For example, the interrelation of system and/or subsystem technologies mandates staff-meeting-level attention to the client-server archetecture.
_______________________________________________
Interchange-users mailing list
Interchange-users@lists.akopia.com
http://lists.akopia.com/mailman/listinfo/interchange-users