Returning an indexable array from a UDT [solved]
Posted: Mon Jan 19, 2009 1:15 pm
Been struggling with this for several hours, and have trawled the forums but can't seem to find the answer.
I want to create a UDT that I can pass a parameters to, and have it return an array which I can then index / access, something like this:
## Content Page Code ##
{get_domain server='xxx.com'}
{foreach from=$get_domain item=row}
Domain: {$row->domain}
Title: {$row->title}
Description: {$row->desc}
{/foreach}
## UDT get_domain Code ##
$server = $params['server'];
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
$result = mysql_query ("SELECT * FROM domains WHERE dom_name = '$server'");
$row = mysql_fetch_array($result);
// result = array(domain,title,desc)
global $gCms;
$smarty = &$gCms->GetSmarty();
$smarty->assign(row, $row);
## / UDT get_domain ##
I want to do a select on an external database and return the results which I can then use in the code, and I want to do it with one DB query, rather than one query for each result field.
Any sample code or help greatfully received

I want to create a UDT that I can pass a parameters to, and have it return an array which I can then index / access, something like this:
## Content Page Code ##
{get_domain server='xxx.com'}
{foreach from=$get_domain item=row}
Domain: {$row->domain}
Title: {$row->title}
Description: {$row->desc}
{/foreach}
## UDT get_domain Code ##
$server = $params['server'];
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
$result = mysql_query ("SELECT * FROM domains WHERE dom_name = '$server'");
$row = mysql_fetch_array($result);
// result = array(domain,title,desc)
global $gCms;
$smarty = &$gCms->GetSmarty();
$smarty->assign(row, $row);
## / UDT get_domain ##
I want to do a select on an external database and return the results which I can then use in the code, and I want to do it with one DB query, rather than one query for each result field.
Any sample code or help greatfully received
