[ic] *** Interchange 4.6 & PgSQL Difficulties ***

Stefan Hornburg racke@linuxia.de
02 Dec 2000 17:49:55 +0100


Marc Aubert <maubert@swisscenter.ch> writes:


[...]

> 
> Questions :
> 
> 1 - [query sql="select * from products where category = 'something' 
> and title LIKE 'something%']
> How to have results from such a SQL query displayed ?
> It seems that the SQL query is nicely transmitted to PgSQL (according 
> to logs), but nothing appears on the Interchange result page. Are we 
> missing something with the tags (we are using the standard 
> Interchange 4.6 demo for now) ?

See below for an example (search the ML archives too !).

> 
> 2 - How to have a FORM sending its result to the page that contains 
> the SQL query so that the 'something' value in the SQL query can be 
> adapted with the FORM's result ?

sth like that should do the trick
<form action=[process] method=post>
<input type=hidden name=mv_todo value=go>
<input type=hidden name=mv_nextpage value=...>

> 
> 3 - A practical example would be definitely appreciated.

[include pages/header.html]
[calc]$Scratch->{workaround}=1;'';[/calc]
[seti related][/seti]
[if session arg]
[seti product_ids][field column="related_products" key="[data session arg]"][/seti]
[/if]
[loop list="[scratch product_ids]"]
[sql type=list query="select code from products where internal_product_id = '[loop-code]'"]
[seti related][sql-code] [scratch related][/seti]
[/sql]
[/loop]
[query hashref=related list=1 more=1 ml=3 sql="select * from products where internal_product_id in ([scratch product_ids])"]
<TABLE CELLSPACING=3 CELLPADDING=0 BORDER=0 WIDTH="100%"><TD colspan="3" BORDER=0 NOWRAP ALIGN=CENTER><img src="__IMAGE_DIR__/titles/accessories.gif"</TD>
<TR BORDER=1 ALIGN=TOP>[list] 
<TD WIDTH="33%" BORDER=1 NOWRAP ALIGN=TOP>
<CENTER>
[seti brand][field name="brand_code" key="[sql-code]"][/seti]
[if type="data" term="brand::large_brand_picture::[scratch brand]"]
<IMG BORDER=0 SRC="brands/large/[data base="brand" field="large_brand_picture" key="[scratch brand]"]" ALT="[data base="brand" field="name" key="[scratch brand]"]">
[else][data base="brand" field="name" key="[scratch brand]"][/else]
[/if]
</CENTER>
</TD>
[/list]
</TR>
<TR BORDER=1 ALIGN=TOP>
[list]
 <TD WIDTH="33%" BORDER=1 NOWRAP ALIGN=TOP>
	<CENTER>
	  <BR>__TABLEFONT1__
	  [if ordered [sql-field code]]
	  <FONT COLOR="RED"><I>[language-field product_title [sql-code]]</I></FONT>
	  [else]
	  [language-field product_title [sql-code]]
	  [/else]
	  [/if]</FONT>
	</CENTER>
      </TD>
[/list]
</TR>
<TR BORDER=1 ALIGN=TOP>
[list]
      <TD WIDTH="33%" BORDER=1 NOWRAP ALIGN=TOP>
	<CENTER>
	  <BR>
	  [page href="[sql-code]"]<IMG BORDER=0 SRC="__IMAGE_DIR__/small/[sql-field small_picture]" ALT="[L]More Info[/L]" >[/page]
	</CENTER>
      </TD>
[/list]
</TR>
<TR>
[list]
<TD WIDTH="33%" BORDER=1 NOWRAP ALIGN=TOP>
	<CENTER>
	  <BR>__TABLEFONT1__
	  [language-field product_short_description [sql-code]]
	  <BR></FONT>
	</CENTER>
      </TD>
[/list]
</TR>
<TR>
[list]
<TD WIDTH="33%" BORDER=1 NOWRAP ALIGN=TOP>
<CENTER>__TABLEFONT1__<B>[currency][sql-price noformat=1][/currency]</B><BR></FONT></CENTER>
</TD>
[/list]
</TR>
<TR>
[list]
<TD>
<CENTER>
<A HREF="[area form="
                    mv_orderpage=related
                    mv_order_item=[sql-code]
                    mv_order_quantity=1 
                    mv_todo=refresh"]" 
                    onMouseOver="window.status='[L]ORDER NOW[/L]'; return true;"
                    onMouseOut="window.status=''; return true;"> 
[if ordered [sql-code]]
<IMG BORDER=0 SRC="icon/inbasket.gif" ALT="[L]ORDER NOW[/L]"</A>
[else]
<IMG BORDER=0 SRC="icon/intobasket.gif" ALT="[L]ORDER NOW[/L]"</A>
[/else]
[/if]
</CENTER>
</TD> 
[/list]
</TR>
</TABLE>

<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH="100%">
<TR>
<TD>
<CENTER>
<FONT SIZE="2">
[more-list but_next.gif but_back.gif 0 0][more][/more-list]
</FONT><BR><BR>
<A HREF="javascript:top.window.close();"><img src="__IMAGE_DIR__/but_close.gif" border="0"><A>
</CENTER>
</TD>
</TR>
</TABLE>

[/query]
[include pages/footer.html]

Ciao
        Racke

-- 
LinuXia Systems && Cobolt NetServices, eCommerce and more
Shop- und Datenbanklösungen mit MiniVend, Firewalls auf Debian-Basis
http://www.linuxia.de - http://www.cobolt.net
--> Junior Officer of the MiniVend/Interchange Bug Patrol <---