Changeset 365 for trunk/dictionary.php


Ignore:
Timestamp:
Mar 9, 2010, 11:29:05 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Jména tabulek v databází upraveny na stejná s prvními velkými písmeny.
  • Upraveno: Doplněny SQL uvozovky do mnoha SQL dotazů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dictionary.php

    r288 r365  
    9393  if(Licence(LICENCE_USER))
    9494  {
    95     $DbResult = $Database->SQLCommand('SELECT `Language` FROM `user` WHERE `ID`='.$_SESSION['UserID']);
     95    $DbResult = $Database->SQLCommand('SELECT `Language` FROM `User` WHERE `ID`='.$_SESSION['UserID']);
    9696    $User = mysql_fetch_assoc($DbResult);
    9797    $_SESSION['language'] = $User['Language'];
     
    144144      if(array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
    145145      {       
    146         $DbResult = $Database->SQLCommand('SELECT * FROM `dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND Language=0');
     146        $DbResult = $Database->SQLCommand('SELECT * FROM `Dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND `Language`=0');
    147147        if(mysql_num_rows($DbResult) > 0)
    148148        {
     
    151151        } else
    152152        {
    153           $DbResult = $Database->SQLCommand('SELECT MAX(Entry) FROM dictionary');
     153          $DbResult = $Database->SQLCommand('SELECT MAX(`Entry`) FROM `Dictionary`');
    154154          $DbRow = mysql_fetch_row($DbResult);
    155155          $Entry = $DbRow[0] + 1;
    156           $Database->SQLCommand('INSERT INTO `dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", 0, 0);');
     156          $Database->SQLCommand('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", 0, 0);');
    157157        }
    158158     
    159         $DbResult = $Database->SQLCommand('SELECT Id FROM `dictionary` WHERE `Entry` = '.$Entry.' AND Language='.$_SESSION['language'].' AND User='.$_SESSION['UserID']);
     159        $DbResult = $Database->SQLCommand('SELECT `Id` FROM `Dictionary` WHERE `Entry` = '.$Entry.' AND `Language`='.$_SESSION['language'].' AND `User`='.$_SESSION['UserID']);
    160160        if(mysql_num_rows($DbResult) > 0)
    161161        {
    162162          $DbRow = mysql_fetch_assoc($DbResult);
    163           $Database->SQLCommand('UPDATE `dictionary` SET `Text`="'.$_POST['Translated'].'", `Description` = "'.$_POST['Description'].'" WHERE Id='.$DbRow['Id']);
     163          $Database->SQLCommand('UPDATE `Dictionary` SET `Text`="'.$_POST['Translated'].'", `Description` = "'.$_POST['Description'].'" WHERE Id='.$DbRow['Id']);
    164164        } else     
    165           $Database->SQLCommand('INSERT INTO `dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$_SESSION['UserID'].', '.$_SESSION['language'].')');
     165          $Database->SQLCommand('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$_SESSION['UserID'].', '.$_SESSION['language'].')');
    166166        echo('Záznam byl uložen!');
    167167      } else echo('Nebyly zaslány všechny položky formuláře.');
     
    169169    if(($_GET['action'] == 'remove') and Licence(LICENCE_USER))
    170170    {
    171       $Database->SQLCommand('DELETE FROM dictionary WHERE User='.$_SESSION['UserID'].' AND Language='.$_SESSION['language'].' AND Entry='.$_GET['entry']);
     171      $Database->SQLCommand('DELETE FROM `Dictionary` WHERE `User`='.$_SESSION['UserID'].' AND `Language`='.$_SESSION['language'].' AND `Entry`='.$_GET['entry']);
    172172    } else
    173173    if(($_GET['action'] == 'modify')  and Licence(LICENCE_USER))
    174174    {
    175       $DbResult = $Database->SQLCommand('SELECT * FROM dictionary WHERE User='.$_SESSION['UserID'].' AND Entry='.$_GET['entry'].' AND Language='.$_SESSION['language']);
     175      $DbResult = $Database->SQLCommand('SELECT * FROM `Dictionary` WHERE `User`='.$_SESSION['UserID'].' AND `Entry`='.$_GET['entry'].' AND `Language`='.$_SESSION['language']);
    176176      $DbRow = mysql_fetch_assoc($DbResult);
    177       $DbResult = $Database->SQLCommand('SELECT * FROM dictionary WHERE User=0 AND Entry='.$_GET['entry'].' AND Language=0');
     177      $DbResult = $Database->SQLCommand('SELECT * FROM `Dictionary` WHERE `User`=0 AND `Entry`='.$_GET['entry'].' AND `Language`=0');
    178178      $DbRow2 = mysql_fetch_assoc($DbResult);
    179179      echo('<form action="dictionary.php?action=save" method="post">'.
     
    216216  if($Search <> '')
    217217  {
    218     $sql = 'SELECT `user`.`user` AS `UserName`, `user`. `ID` AS `UserID`, `T3`.`Entry`, `T3`.`Original`, `T3`.`Translated`, `T3`.`Description` FROM (SELECT T2.User, `T1`.Language, `T1`.`Text` AS Original, `T2`.`Text` AS `Translated`, `T2`.`Description`, `T1`.`Entry` AS `Entry` FROM `dictionary` AS `T1` JOIN `dictionary` AS `T2` ON `T2`.`Entry` = `T1`.`Entry` AND `T2`.`Language` = '.$_SESSION['language'].' WHERE LOWER(T1.Text) LIKE LOWER("%'.$Search.'%") OR LOWER(T1.Description) LIKE LOWER("%'.$Search.'%") ) AS T3 JOIN `user` ON `user`.`ID` = `T3`.`User` WHERE `T3`.`Language` = 0';
    219   } else $sql = 'SELECT `user`.`user` AS `UserName`, `ID` AS `UserID`, `T3`.`Entry`, `T3`.`Original`, `T3`.`Translated`, `T3`.`Description` FROM (SELECT T2.User, `T1`.Language, `T1`.`Text` AS Original, `T2`.`Text` AS `Translated`, `T2`.`Description`, `T1`.`Entry` AS `Entry` FROM `dictionary` AS `T1` JOIN `dictionary` AS `T2` ON `T2`.`Entry` = `T1`.`Entry` AND `T2`.`Language` = '.$_SESSION['language'].') AS T3 JOIN `user` ON `user`.`ID` = `T3`.`User` WHERE `T3`.`Language` = 0';
    220 
    221   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM ('.$sql.') AS T1');
     218    $sql = 'SELECT `User`.`Name` AS `UserName`, `User`. `ID` AS `UserID`, `T3`.`Entry`, `T3`.`Original`, `T3`.`Translated`, `T3`.`Description` FROM (SELECT `T2`.`User`, `T1`.`Language`, `T1`.`Text` AS `Original`, `T2`.`Text` AS `Translated`, `T2`.`Description`, `T1`.`Entry` AS `Entry` FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` ON `T2`.`Entry` = `T1`.`Entry` AND `T2`.`Language` = '.$_SESSION['language'].' WHERE LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%") OR LOWER(`T1`.`Description`) LIKE LOWER("%'.$Search.'%") ) AS `T3` JOIN `User` ON `User`.`ID` = `T3`.`User` WHERE `T3`.`Language` = 0';
     219  } else $sql = 'SELECT `User`.`Name` AS `UserName`, `ID` AS `UserID`, `T3`.`Entry`, `T3`.`Original`, `T3`.`Translated`, `T3`.`Description` FROM (SELECT `T2`.`User`, `T1`.Language, `T1`.`Text` AS `Original`, `T2`.`Text` AS `Translated`, `T2`.`Description`, `T1`.`Entry` AS `Entry` FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` ON `T2`.`Entry` = `T1`.`Entry` AND `T2`.`Language` = '.$_SESSION['language'].') AS `T3` JOIN `User` ON `User`.`ID` = `T3`.`User` WHERE `T3`.`Language` = 0';
     220
     221  $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM ('.$sql.') AS `T1`');
    222222  $DbRow = mysql_fetch_row($DbResult);
    223223  $PageList = GetPageList($DbRow[0]); 
Note: See TracChangeset for help on using the changeset viewer.