//First check if the database has the Selectable attribute in the references to only select those references.
//--------------------------------------------------------------------------------------------------------------------------
$SQL="SELECT sysobjects.name AS Exp1 FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id WHERE (sysobjects.name LIKE 'Reference') AND (syscolumns.name LIKE N'Selectable')";
echo "
".$SQL;
$rs=mssql_query($SQL, $dbcon);
if (mssql_num_rows($rs)>0) {
$SelectableColExist=true;
} else {
$SelectableColExist=false;
}
//I create a different SQL depending if the Visible column exist or not in the database
if ($SelectableColExist==true){
$SQL="SELECT RefCache, RefId FROM dbo.Reference WHERE (Selectable = 1)";
} else {
$SQL="SELECT DISTINCT RefCache, RefId FROM dbo.Reference INNER JOIN dbo.PTaxon ON Reference.RefId = PTaxon.PTRefFk";
}
//--------------------------------------------------------------------------------------------------------------------------
//Select all the available sources to present into the Reference box
echo "
".$SQL;
$rs=mssql_query($SQL, $dbcon);
?>
Search! | |
|