Ignore:
Timestamp:
Feb 28, 2016, 10:54:30 AM (8 years ago)
Author:
chronos
Message:
  • Modified: Use object oriented approach for page drawing using Application class.
  • Added: SQL updated will be automatic using UpdateTrace.php file.
  • Added: Use generic setup page at URL /setup for SQL structure update.
  • Modified: Update Common package to newer version.
Location:
trunk/Application
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Application/UpdateTrace.php

    r68 r69  
    11<?php
    22
    3 class UpdateTrace
     3function FullInstall($Manager)
    44{
    5   var $Manager;
    6 
    7   function FullInstall($Manager)
    8   {
    9     $this->Manager->Execute('CREATE TABLE IF NOT EXISTS `SystemVersion` (
     5   $Manager->Execute('CREATE TABLE IF NOT EXISTS `SystemVersion` (
    106  `Id` int(11) NOT NULL AUTO_INCREMENT,
    117  `Revision` int(11) NOT NULL,
    128  PRIMARY KEY (`Id`)
    139) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
    14     $this->Manager->Execute('INSERT INTO `SystemVersion` (`Id`, `Version`) VALUES (NULL, 65);');
    15   }
     10  $Manager->Execute('INSERT INTO `SystemVersion` (`Id`, `Revision`) VALUES (NULL, 65);');
     11  $Manager->Execute('CREATE TABLE IF NOT EXISTS `measure` (
     12  `Id` int(11) NOT NULL auto_increment,
     13  `Name` varchar(255) collate utf8_general_ci NOT NULL,
     14  `Description` varchar(255) collate utf8_general_ci NOT NULL,
     15  `Divider` int(11) NOT NULL default 1,
     16  `Unit` varchar(16) collate utf8_general_ci NOT NULL,
     17  `Continuity` tinyint(1) NOT NULL default 0,
     18  `Period` int(11) NOT NULL default 60,
     19  `OldName` varchar(32) collate utf8_general_ci NOT NULL,
     20  `PermissionView` varchar(255) collate utf8_general_ci NOT NULL default "all",
     21  `PermissionAdd` varchar(255) collate utf8_general_ci NOT NULL default "localhost.localdomain",
     22  `Info` varchar(255) collate utf8_general_ci NOT NULL,
     23  `Enabled` int(11) NOT NULL default 1,
     24  `Cumulative` int(11) NOT NULL default 0,
     25  `DataTable` varchar(32) collate utf8_general_ci NOT NULL default "data",
     26  `DataType` varchar(32) collate utf8_general_ci NOT NULL,
     27  PRIMARY KEY  (`Id`)
     28) ENGINE=InnoDB  DEFAULT CHARSET=utf8;');
     29}
    1630
    17   function UpdateTo67($Manager)
    18   {
    19     $this->Manager->Execute('RENAME TABLE `measure` TO `Measure`;');
    20     $this->Manager->Execute('CREATE TABLE IF NOT EXISTS `Permission` (
     31function UpdateTo67($Manager)
     32{
     33  $Manager->Execute('RENAME TABLE `measure` TO `Measure`;');
     34/*
     35   $Manager->Execute('CREATE TABLE IF NOT EXISTS `Permission` (
    2136  `Id` int(11) NOT NULL AUTO_INCREMENT,
    2237  `Measure` int(11) NOT NULL,
     
    2641  KEY `Measure` (`Measure`)
    2742) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
    28     $this->Manager->Execute('ALTER TABLE `Permission` ADD FOREIGN KEY (`Measure`) '.
    29     'REFERENCES `Measure`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
    30     $DbResult = $this->Manager->Execute('SELECT `Id`, `PermissionAdd` FROM `Measure`');
    31     while($DbRow = $DbResult->fetch_assoc())
    32     {
    33           $this->Manager->Execute('INSERT INTO `Permission` (`Measure`, `Operation`) VALUES ('.
     43  $Manager->Execute('ALTER TABLE `Permission` ADD FOREIGN KEY (`Measure`) '.
     44  'REFERENCES `Measure`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
     45  $DbResult = $Manager->Execute('SELECT `Id`, `PermissionAdd` FROM `Measure`');
     46  while($DbRow = $DbResult->fetch_assoc())
     47  {
     48    $Manager->Execute('INSERT INTO `Permission` (`Measure`, `Operation`) VALUES ('.
    3449            $DbRow['Id'].', "add");');
    3550        }
    36     $DbResult = $this->Manager->Execute('SELECT `Id`, `PermissionView` FROM `Measure`');
    37     while($DbRow = $DbResult->fetch_assoc())
    38     {
    39           $this->Manager->Execute('INSERT INTO `Permission` (`Measure`, `Operation`) VALUES ('.
     51  $DbResult = $Manager->Execute('SELECT `Id`, `PermissionView` FROM `Measure`');
     52  while($DbRow = $DbResult->fetch_assoc())
     53  {
     54          $Manager->Execute('INSERT INTO `Permission` (`Measure`, `Operation`) VALUES ('.
    4055            $DbRow['Id'].', "view");');
    41         }
    42         //$this->Manager->Execute('');
    4356  }
     57  */
     58}
    4459
    45   function __construct()
     60class Updates
     61{
     62  function Get()
    4663  {
    47     $this->Updates = array(
     64    return(array(
    4865      65 => array('Revision' => 67, 'Function' => 'UpdateTo67'),
    49     );
     66    ));
    5067  }
    5168}
Note: See TracChangeset for help on using the changeset viewer.