[ic] SQL as products database

tamas.kohegyi@unforgettable.com tamas.kohegyi@unforgettable.com
Tue, 10 Apr 2001 13:09:28 +0300


Hi,

On Tuesday 10 April 2001 12:35, you wrote:
> I have -
> Database products products.txt dbi:Pg:dbname=test
> in the catalog.cfg
> How I can get information from the database now?
> I've tried to use [loop] and [query sql="select * from products"] - it
> does not work!

Do not use * in your query. Try to use "select this,that from products"
See the minivend 3.x documentation/tag reference [sql ...] tags for examples.

> I have all information in Postgresql - users, products, etc,
> and I want to use interchange, but I don't understand, how I can get
> information from PostgreSQL?

See the minivend 3.x documentation/tag reference [sql ...] tags for examples.

you can use the [perl] tag also, e.g:

[comment]
Sql:[scratch an_sql]<BR>
[/comment]
<TABLE BORDER=1 CELLSPACING=0 HALIGN=CENTER WIDTH=100%>
[perl tables="products" global=1 interpolate=1]
  my $dbh = $Sql{products};
  my $tmp = $Scratch->{an_sql};
  my $sth = $dbh->prepare($tmp);
  $sth->execute();
  my $out;
  my $a_reply;
  my @record;
  while(@record = $sth->fetchrow()) {
    $a_reply = $Tag->area({href => 'products_detail',arg => @record[0],});
    $out .= "<TR>\n";
    $out .= "<TD><A href=\"$a_reply\">@record[1]</A></TD>\n";
    $out .= "<TD>@record[2]</TD>\n";
    $out .= "<TD>@record[3]</TD>\n";
    $out .= "<TD>@record[4]</TD>\n";
    $out .= "</TR>\n";
    };
  $out;
[/perl]
</TABLE>

Regards,
Tamas