Ignore:
Timestamp:
Oct 19, 2008, 8:16:37 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Mezitabulkovéí odkazy na položky jsou nyní realizovány jako odkazy na id položky(ItemId) namísto id řádku v tabulce(Id).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • types/PointerOneToOne.php

    r12 r15  
    55  global $Database, $Lists;
    66
     7  //print_r($Item);
    78  $Columns = '';
    89  $TargetTable = $Type['Parameters'][0];
     
    1011  foreach($Lists[$TargetTable]['Items'] as $ListItem)
    1112    if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
    12   $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
    13   $DbResult = $Database->select($TargetTable, $Columns, 'Id='.$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');
    1415  //echo($Database->LastQuery);
    1516  if($DbResult->num_rows > 0)
     
    2829  foreach($Lists[$TargetTable]['Items'] as $ListItem)
    2930    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');
    3233  //echo($Database->LastQuery);
    3334  if($DbResult->num_rows > 0)
     
    4748  $TargetTable = $Type['Parameters'][0];
    4849  $TargetName = GetTablePointerName($Type, $Item);
    49   $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>';
     50  $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName['ItemId'].'">'.$TargetName['Name'].'</a>';
    5051  return($Output);
    5152}
     
    6162  foreach($TargetNameList as $TargetName)
    6263  {
    63     if($Item['Value'] == $TargetName['Id']) $Selected = ' selected="1"'; else $Selected = '';
    64     $Output .= '<option value="'.$TargetName['Id'].'"'.$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>';
    6566  }
    6667  $Output .= '</select>';
Note: See TracChangeset for help on using the changeset viewer.