Changeset 28 for types


Ignore:
Timestamp:
Dec 8, 2008, 11:06:23 AM (16 years ago)
Author:
george
Message:
  • Upraveno: Systém ukládání dat do databáze přepracován na jednodušší. Původní záměr počítal s verzováním položek seznamů čímž se komplikovaly SQL dotazy. Systém sledování změn bude později řešen přes tabulku Audit.
  • Odebráno: Sloupce tabulek Author, ItemId, CreationTime, DeletionTime, ValidtTimeFrom a ValidTimeTo.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • types/PointerOneToOne.php

    r26 r28  
    1111    $List = GetListDefinition($Type['Parameters'][0]);
    1212    $TargetTable = $List['TableName'];
     13    //echo($TargetTable.'<');
     14    //print_r($List);
    1315    foreach($List['Items'] as $Index => $ListItem)
    1416    {
     
    2123        {
    2224          //print_r($Type);
    23           $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Item['Value'].' ORDER BY Id DESC LIMIT 1');
     25          $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Item['Value']);
    2426          $DbRow = $DbResult->fetch_assoc();
    25           $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['ItemId'], 'SourceItemId' => 0);
     27          $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0);
    2628          $SubTarget = $this->GetTablePointerName($Type, $DefinitionItem);
    2729          $Columns .= '"'.$SubTarget['Name'].' ",';
     
    2931      }
    3032    }
    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);
    3438    if($DbResult->num_rows > 0)
    3539    {
     
    4650    $TargetTable = $List['TableName'];
    4751    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.'`');
    5155    //echo($Database->LastQuery);
    5256    if($DbResult->num_rows > 0)
    5357    {
    5458
    55       $Result = array(array('Name' => 'Žádný', 'Id' => 0, 'ItemId' => 0));
     59      $Result = array(array('Name' => 'Žádný', 'Id' => 0));
    5660      while($DbRow = $DbResult->fetch_assoc())
    5761        $Result[] = $DbRow;
     
    6771    $TargetTable = $Type['Parameters'][0];
    6872    $TargetName = $this->GetTablePointerName($Type, $Item);
    69     $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName['ItemId'].'">'.$TargetName['Name'].'</a>';
     73    $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>';
    7074    return($Output);
    7175  }
     
    8185    foreach($TargetNameList as $TargetName)
    8286    {
    83       if($Item['Value'] == $TargetName['ItemId']) $Selected = ' selected="1"'; else $Selected = '';
    84       $Output .= '<option value="'.$TargetName['ItemId'].'"'.$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>';
    8589    }
    8690    $Output .= '</select>';
Note: See TracChangeset for help on using the changeset viewer.