- Timestamp:
- Dec 8, 2008, 11:06:23 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
types/PointerOneToOne.php
r26 r28 11 11 $List = GetListDefinition($Type['Parameters'][0]); 12 12 $TargetTable = $List['TableName']; 13 //echo($TargetTable.'<'); 14 //print_r($List); 13 15 foreach($List['Items'] as $Index => $ListItem) 14 16 { … … 21 23 { 22 24 //print_r($Type); 23 $DbResult = $Database->select($List['TableName'], '*', 'I temId='.$Item['Value'].' ORDER BY Id DESC LIMIT 1');25 $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Item['Value']); 24 26 $DbRow = $DbResult->fetch_assoc(); 25 $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['I temId'], 'SourceItemId' => 0);27 $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0); 26 28 $SubTarget = $this->GetTablePointerName($Type, $DefinitionItem); 27 29 $Columns .= '"'.$SubTarget['Name'].' ",'; … … 29 31 } 30 32 } 31 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, ItemId, Id'; 32 $DbResult = $Database->select($TargetTable, $Columns, 'ItemId='.$Item['Value'].' AND (DeletionTime IS NULL) ORDER BY Id DESC LIMIT 1'); 33 echo($Database->LastQuery); 33 $Columns = substr($Columns, 0, -1); 34 if($Columns == '') $Columns = 'Id AS Name, Id'; 35 else $Columns = 'CONCAT('.$Columns.') AS Name, Id'; 36 $DbResult = $Database->select($TargetTable, $Columns, 'Id='.$Item['Value']); 37 //echo($Database->LastQuery); 34 38 if($DbResult->num_rows > 0) 35 39 { … … 46 50 $TargetTable = $List['TableName']; 47 51 foreach($List['Items'] as $ListItem) 48 if($ListItem['VisibleInPointer'] == 1) $Columns .= ' t1.`'.$ListItem['Name'].'`," ",';49 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, t1.Id, t1.ItemId, t1.DeletionTime';50 $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');52 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",'; 53 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id'; 54 $DbResult = $Database->query('SELECT '.$Columns.' FROM `'.$TargetTable.'`'); 51 55 //echo($Database->LastQuery); 52 56 if($DbResult->num_rows > 0) 53 57 { 54 58 55 $Result = array(array('Name' => 'Žádný', 'Id' => 0 , 'ItemId' => 0));59 $Result = array(array('Name' => 'Žádný', 'Id' => 0)); 56 60 while($DbRow = $DbResult->fetch_assoc()) 57 61 $Result[] = $DbRow; … … 67 71 $TargetTable = $Type['Parameters'][0]; 68 72 $TargetName = $this->GetTablePointerName($Type, $Item); 69 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['I temId'].'">'.$TargetName['Name'].'</a>';73 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>'; 70 74 return($Output); 71 75 } … … 81 85 foreach($TargetNameList as $TargetName) 82 86 { 83 if($Item['Value'] == $TargetName['I temId']) $Selected = ' selected="1"'; else $Selected = '';84 $Output .= '<option value="'.$TargetName['I temId'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';87 if($Item['Value'] == $TargetName['Id']) $Selected = ' selected="1"'; else $Selected = ''; 88 $Output .= '<option value="'.$TargetName['Id'].'"'.$Selected.'>'.$TargetName['Name'].'</option>'; 85 89 } 86 90 $Output .= '</select>';
Note:
See TracChangeset
for help on using the changeset viewer.