[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [mv] Describe Mysql-tables in Minivend
****** message to minivend-users from Mike Heins <mikeh@minivend.com> ******
Quoting Adam Kett (adam@opusvl.com):
> I was wondering If anyone know's how to do the following
> because it is something that would make life that much
> more dynamic :)
>
>
>
> list perm fields:
> <P>
In MV4, pretty easy.
This is fairly well documented, I think -- have you looked?
If it is a table Minivend is aware of:
[perl tables=your_table]
return join "\n", $Db{your_table}->columns();
[/perl]
Otherwise if it is in a database Minivend is attached to
(like products):
[perl tables=products]
my $dbh = $Sql{products};
my $sth;
# Not all drivers support this
#@interested = $dbh->tables();
@interested = qw/products pricing inventory/;
my $out = "<PRE>Table/view list:\n\n";
foreach my $tbl (@interested) {
$out .= " $tbl:\n\t";
$sth = $dbh->prepare("select * from $tbl limit 1");
$sth->execute();
$out .= join "\n\t", @{$sth->{NAME}};
$out .= "\n\n";
}
return "$out</PRE>";
[/perl]
You can even use DBI's type_info_all, I think. See the DBI docs.
Bear in mind that you must have Safe::Hole installed (part of
Bundle::Minivend).
If you have dynamic tables, you don't want them attached as
standard Minivend tables. Access them via [query sql="..."]
and [sql-param name], for Minivend wants to know the columns
beforehand.
Also, you can access the results of [query arrayref=tmp]
with $Tmp->{tmp}.
This is *all* documented, by the way.
--
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH 45056
phone +1.513.523.8220 fax 7501 <heins@akopia.com>
Friends don't let friends use Outlook. -- Bob Blaylock
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list