[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ic] Re: Accessing looped data in a usertag


On Tue, 18 Mar 2008, Ron Phipps wrote:

You may want to try using a query to pull the orderline data, something like this in a usertag:

my $db = Vend::Data::database_exists_ref('orderline');
my $sql = "SELECT code, sku FROM orderline WHERE order_number = '1234'";

my $dbh = $db->[$Vend::Table::DBI::DBI];
my $sth = $dbh->prepare($sql);
$sth->execute();

if ($sth) {
	while (my $sql_results = $sth->fetchrow_hashref()) {
		my $code = $$sql_results{code};
		my $sku = $$sql_results{sku};
	}
}

Grant,

Ron's advice above is for a global usertag; if you want to use a catalog usertag, use this to get the $dbh instead:

my $dbh = $Sql{orderline} or die "Couldn't get orderline handle\n";

And in the page that calls the usertag you'll need to pre-open the database handle with something like:

[perl tables="orderline"][/perl]

before you call the tag.

HTH,
Jon

--
Jon Jensen
End Point Corporation
http://www.endpoint.com/
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.