Changeset 28 for lists


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.
Location:
lists
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lists/SystemList.php

    r26 r28  
    99    $Database->query('CREATE TABLE IF NOT EXISTS `'.$Parameters['TableName'].'` (
    1010    `Id` int(11) NOT NULL auto_increment,
    11     `ItemId` int(11) NOT NULL,
    12     `Author` int(11) NOT NULL,
    13     `ValidTimeFrom` datetime default NULL,
    14     `ValidTimeTo` datetime default NULL,
    15     `CreationTime` datetime default NULL,
    16     `DeletionTime` datetime default NULL,
    1711    PRIMARY KEY  (`Id`)
    1812    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
    19     $Database->query('ALTER TABLE `'.$Parameters['TableName'].'` ADD INDEX ( `ItemId` );');
    2013    //echo($Database->LastQuery);
    2114  }
     
    2518    global $Database;
    2619
    27     $DbResult = $Database->query('SELECT `TableName` FROM `'.$Parameters['ListTableName'].'` WHERE ItemId='.$Parameters['ItemId'].' ORDER BY `Id` DESC LIMIT 1,1');
     20    $DbResult = $Database->query('SELECT `TableName` FROM `'.$Parameters['ListTableName'].'` WHERE Id='.$Parameters['Id']);
    2821    $DbRow = $DbResult->fetch_assoc();
    2922    if($DbRow['TableName'] != $Parameters['TableName'])
    3023      $Database->query('RENAME TABLE `'.$DbRow['TableName'].'` TO `'.$Parameters['TableName'].'`');
    3124  }
     25
     26  function ApplySQLToItems($SQL)
     27  {
     28    global $Database;
     29
     30    $DbResult = $Database->query('SELECT `TableName` FROM `SystemList`');
     31    while($DbRow = $DbResult->fetch_assoc())
     32    {
     33      $Database->query(str_replace('`TableName`', '`'.$DbRow['TableName'].'`', $SQL));
     34    }
     35  }
    3236}
    3337
  • lists/SystemListItem.php

    r27 r28  
    77    global $Database;
    88
    9     $Database->query('UPDATE SystemListItem AS Table1 SET Sequence = (SELECT COUNT(*) FROM (SELECT * FROM SystemListItem) AS Table2 WHERE (Table1.ItemId = Table2.ItemId) AND ((Table2.Sequence < Table1.Sequence) OR ((Table1.Sequence = Table2.Sequence) AND (Table2.Id < Table1.Id))))');
     9    $Database->query('UPDATE SystemListItem AS Table1 SET Sequence = (SELECT COUNT(*) FROM (SELECT * FROM SystemListItem) AS Table2 WHERE ((Table2.Sequence < Table1.Sequence) OR ((Table1.Sequence = Table2.Sequence) AND (Table2.Id < Table1.Id))))');
    1010  }
    1111
     
    1515
    1616    //print_r($Parameters);
    17     $DbResult = $Database->query('SELECT DbDataType FROM SystemType WHERE ItemId='.$Parameters['Type'].' ORDER BY Id DESC LIMIT 1');
     17    $DbResult = $Database->query('SELECT DbDataType FROM SystemType WHERE Id='.$Parameters['Type']);
    1818    //echo($Database->LastQuery);
    1919    $DbRow = $DbResult->fetch_assoc();
    20     $DbResult = $Database->query('SELECT TableName FROM SystemList WHERE ItemId='.$Parameters[$Parameters['Column']].' ORDER BY Id DESC LIMIT 1');
     20    $DbResult = $Database->query('SELECT TableName FROM SystemList WHERE Id='.$Parameters[$Parameters['Column']]);
    2121    //echo($Database->LastQuery);
    2222    $DbRow2 = $DbResult->fetch_assoc();
  • lists/include.php

    r24 r28  
    55include('lists/SystemListItem.php');
    66
    7 define('ListSystemLogId', 20);
     7define('ListSystemLogId', 59);
    88
    99?>
Note: See TracChangeset for help on using the changeset viewer.