Changeset 31 for types


Ignore:
Timestamp:
Dec 16, 2008, 1:47:05 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Nezobrazovat vybraný sloupec v podseznamech.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • types/PointerOneToOne.php

    r30 r31  
    2323        {
    2424          //print_r($Type);
    25           $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $List['TableName'], 'Condition' => 'Id='.$Item['Value']));
     25          $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $List['TableName'], 'Condition' => $List['IdName'].'='.$Item['Value']));
    2626          $DbRow = $DbResult->fetch_assoc();
    2727          $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0);
     
    3232    }
    3333    $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(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns, 'Condition' => 'Id='.$Item['Value']));
     34    if($Columns == '') $Columns = '`'.$List['IdName'].'` AS `Name`, `'.$List['IdName'].'`';
     35      else $Columns = 'CONCAT('.$Columns.') AS `Name`, `'.$List['IdName'].'`';
     36    $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns, 'Condition' => $List['IdName'].'='.$Item['Value']));
    3737    //echo($Database->LastQuery);
    3838    if($DbResult->num_rows > 0)
     
    5151    foreach($List['Items'] as $ListItem)
    5252      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.'`');
     53    $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, `'.$List['IdName'].'`';
     54    $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns));
    5555    //echo($Database->LastQuery);
    5656    if($DbResult->num_rows > 0)
     
    6969
    7070    $Type = GetTypeDefinition($Item['Type']);
     71    $List = GetListDefinition($Type['Parameters'][0]);
    7172    $TargetTable = $Type['Parameters'][0];
    7273    $TargetName = $this->GetTablePointerName($Type, $Item);
    73     $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>';
     74    $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName[$List['IdName']].'">'.$TargetName['Name'].'</a>';
    7475    return($Output);
    7576  }
     
    8081
    8182    $Type = $Types[$Item['Type']];
     83    $List = GetListDefinition($Type['Parameters'][0]);
    8284    $Output = '<select name="'.$Item['Name'].'">';
    8385    $TargetNameList = $this->GetTablePointerNameList($Type, $Item);
     
    8587    foreach($TargetNameList as $TargetName)
    8688    {
    87       if($Item['Value'] == $TargetName['Id']) $Selected = ' selected="1"'; else $Selected = '';
    88       $Output .= '<option value="'.$TargetName['Id'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';
     89      if($Item['Value'] == $TargetName[$List['IdName']]) $Selected = ' selected="1"'; else $Selected = '';
     90      $Output .= '<option value="'.$TargetName[$List['IdName']].'"'.$Selected.'>'.$TargetName['Name'].'</option>';
    8991    }
    9092    $Output .= '</select>';
Note: See TracChangeset for help on using the changeset viewer.