<?php
function fn_types_c($aql)
{
	$data = $aql->Consume(1);
	
	global $db;
	$apool = array();
	
	$mt = microtime(true);
	
	$existing = array();
	
	global $debug;
	if ($debug == true) echo '[ Getting Assets By Type';
		
	$extra = "";	
	
	$items = array($data[0]->value);
	if (!is_array($items))
	{
		$extra = " AND name LIKE ".$db->quote('%'.$items.'%');
	}
	else
	{
		$extra = " AND name LIKE ".$db->quote('%'.$items[0].'%');
	}
		
	$query = $db->query("SELECT name,id FROM assets WHERE type=1".$extra." ORDER BY name");
	$typelist = array();
	while($row = $query->fetch(PDO::FETCH_ASSOC)) 
	{
		$typelist[strtolower($row['name'])] = $row['id'];
		$apool[] = $row['id'];
	}
			
	$a = new AQLStackElement();
	$a->typename = "assetlist";
	$a->islist = true;
	$a->value = $apool;
	array_push($aql->stack,$a);

}
?>