- Timestamp:
- Oct 19, 2008, 8:16:37 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
types/PointerOneToOne.php
r12 r15 5 5 global $Database, $Lists; 6 6 7 //print_r($Item); 7 8 $Columns = ''; 8 9 $TargetTable = $Type['Parameters'][0]; … … 10 11 foreach($Lists[$TargetTable]['Items'] as $ListItem) 11 12 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",'; 12 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, I d';13 $DbResult = $Database->select($TargetTable, $Columns, 'I d='.$Item['Value']);13 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, ItemId, Id'; 14 $DbResult = $Database->select($TargetTable, $Columns, 'ItemId='.$Item['Value'].' AND (DeletionTime IS NULL) ORDER BY Id DESC LIMIT 1'); 14 15 //echo($Database->LastQuery); 15 16 if($DbResult->num_rows > 0) … … 28 29 foreach($Lists[$TargetTable]['Items'] as $ListItem) 29 30 if($ListItem['VisibleInPointer'] == 1) $Columns .= 't1.`'.$ListItem['Name'].'`," ",'; 30 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, t1.Id, t1.ItemId ';31 $DbResult = $Database->query('SELECT '.$Columns.' FROM `'.$TargetTable.'` AS t1 LEFT JOIN `'.$TargetTable.'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)');31 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, t1.Id, t1.ItemId, t1.DeletionTime'; 32 $DbResult = $Database->query('SELECT t3.* FROM (SELECT '.$Columns.' FROM `'.$TargetTable.'` AS t1 LEFT JOIN `'.$TargetTable.'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)) AS t3 WHERE t3.DeletionTime IS NULL'); 32 33 //echo($Database->LastQuery); 33 34 if($DbResult->num_rows > 0) … … 47 48 $TargetTable = $Type['Parameters'][0]; 48 49 $TargetName = GetTablePointerName($Type, $Item); 49 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['I d'].'">'.$TargetName['Name'].'</a>';50 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['ItemId'].'">'.$TargetName['Name'].'</a>'; 50 51 return($Output); 51 52 } … … 61 62 foreach($TargetNameList as $TargetName) 62 63 { 63 if($Item['Value'] == $TargetName['I d']) $Selected = ' selected="1"'; else $Selected = '';64 $Output .= '<option value="'.$TargetName['I d'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';64 if($Item['Value'] == $TargetName['ItemId']) $Selected = ' selected="1"'; else $Selected = ''; 65 $Output .= '<option value="'.$TargetName['ItemId'].'"'.$Selected.'>'.$TargetName['Name'].'</option>'; 65 66 } 66 67 $Output .= '</select>';
Note:
See TracChangeset
for help on using the changeset viewer.