Changeset 23 for lists


Ignore:
Timestamp:
Oct 22, 2008, 12:54:08 PM (16 years ago)
Author:
george
Message:
  • Opraveno: Odkazy na konstanty id typů.
  • Upraveno: Definice událostí manipulace se seznamy jako třídy a jejich načítání "na přání".
Location:
lists
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lists/SystemList.php

    r16 r23  
    11<?php
    22
    3 function ListSystemListOnAdd($Parameters)
     3class ListSystemList
    44{
    5   global $Database;
     5  function OnAdd($Parameters)
     6  {
     7    global $Database;
    68
    7   $Database->query('CREATE TABLE IF NOT EXISTS `'.$Parameters['TableName'].'` (
    8   `Id` int(11) NOT NULL auto_increment,
    9   `ItemId` int(11) NOT NULL,
    10   `Author` int(11) NOT NULL,
    11   `ValidTimeFrom` datetime default NULL,
    12   `ValidTimeTo` datetime default NULL,
    13   `CreationTime` datetime default NULL,
    14   `DeletionTime` datetime default NULL,
    15   PRIMARY KEY  (`Id`)
    16   ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
    17   //echo($Database->LastQuery);
    18 }
     9    $Database->query('CREATE TABLE IF NOT EXISTS `'.$Parameters['TableName'].'` (
     10    `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,
     17    PRIMARY KEY  (`Id`)
     18    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     19    //echo($Database->LastQuery);
     20  }
    1921
    20 function ListSystemListOnEdit($Parameters)
    21 {
    22   global $Database;
     22  function ListSystemListOnEdit($Parameters)
     23  {
     24    global $Database;
    2325
    24   $DbResult = $Database->query('SELECT `TableName` FROM `'.$Parameters['ListTableName'].'` WHERE ItemId='.$Parameters['ItemId'].' ORDER BY `Id` DESC LIMIT 1,1');
    25   $DbRow = $DbResult->fetch_assoc();
    26   if($DbRow['TableName'] != $Parameters['TableName'])
    27     $Database->query('RENAME TABLE `'.$DbRow['TableName'].'` TO `'.$Parameters['TableName'].'`');
     26    $DbResult = $Database->query('SELECT `TableName` FROM `'.$Parameters['ListTableName'].'` WHERE ItemId='.$Parameters['ItemId'].' ORDER BY `Id` DESC LIMIT 1,1');
     27    $DbRow = $DbResult->fetch_assoc();
     28    if($DbRow['TableName'] != $Parameters['TableName'])
     29      $Database->query('RENAME TABLE `'.$DbRow['TableName'].'` TO `'.$Parameters['TableName'].'`');
     30  }
    2831}
    2932
  • lists/SystemListItem.php

    r16 r23  
    11<?php
    22
    3 function ListSystemListItemOnAdd($Parameters)
     3class ListSystemListItem
    44{
    5   global $Database;
     5  function OnAdd($Parameters)
     6  {
     7    global $Database;
    68
    7   //print_r($Parameters);
    8   $DbResult = $Database->query('SELECT DbDataType FROM SystemType WHERE ItemId='.$Parameters['Type'].' ORDER BY Id DESC LIMIT 1');
    9   //echo($Database->LastQuery);
    10   $DbRow = $DbResult->fetch_assoc();
    11   $DbResult = $Database->query('SELECT TableName FROM SystemList WHERE ItemId='.$Parameters[$Parameters['Column']].' ORDER BY Id DESC LIMIT 1');
    12   //echo($Database->LastQuery);
    13   $DbRow2 = $DbResult->fetch_assoc();
    14   $Database->query('ALTER TABLE `'.$DbRow2['TableName'].'` ADD `'.$Parameters['Name'].'` '.$DbRow['DbDataType'].' NOT NULL ;');
    15   //echo($Database->LastQuery);
     9    //print_r($Parameters);
     10    $DbResult = $Database->query('SELECT DbDataType FROM SystemType WHERE ItemId='.$Parameters['Type'].' ORDER BY Id DESC LIMIT 1');
     11    //echo($Database->LastQuery);
     12    $DbRow = $DbResult->fetch_assoc();
     13    $DbResult = $Database->query('SELECT TableName FROM SystemList WHERE ItemId='.$Parameters[$Parameters['Column']].' ORDER BY Id DESC LIMIT 1');
     14    //echo($Database->LastQuery);
     15    $DbRow2 = $DbResult->fetch_assoc();
     16    $Database->query('ALTER TABLE `'.$DbRow2['TableName'].'` ADD `'.$Parameters['Name'].'` '.$DbRow['DbDataType'].' NOT NULL ;');
     17    //echo($Database->LastQuery);
     18  }
    1619}
    1720
Note: See TracChangeset for help on using the changeset viewer.