Changeset 20


Ignore:
Timestamp:
Oct 22, 2008, 9:31:11 AM (16 years ago)
Author:
george
Message:
  • Upraveno: Redukce použité paměti změnou načítání seznamů "na přání" místo všech najednou.
  • Upraveno: Použití fetch_assoc a fetch_row místo společného fetch_array,
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • base.php

    r19 r20  
    120120  $DbResult = $Database->query('SELECT COUNT(t2.Id) AS Count FROM (SELECT DISTINCT(ItemId) as Id FROM `'.$List['TableName'].'` as t1 WHERE 1'.$Where.') as t2');
    121121  //echo($Database->LastQuery.'<br>');
    122   $DbRow = $DbResult->fetch_array();
     122  $DbRow = $DbResult->fetch_row();
    123123  $TotalItemCount = $DbRow[0];
    124124
    125125  $DbResult = $Database->query('SELECT * FROM `'.$List['TableName'].'` AS t1 WHERE 1'.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);
    126126  //echo($Database->LastQuery.'<br>');
    127   while($DbRow = $DbResult->fetch_array())
     127  while($DbRow = $DbResult->fetch_assoc())
    128128  {
    129129    $Output .= '<tr>';
     
    155155  if(!CheckPermission('Write', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
    156156  $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1');
    157   while($DbRow = $DbResult->fetch_array())
     157  while($DbRow = $DbResult->fetch_assoc())
    158158  {
    159159    $DefinitionItems = array();
     
    194194  if(!CheckPermission('Write', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
    195195  $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1');
    196   while($DbRow = $DbResult->fetch_array())
     196  while($DbRow = $DbResult->fetch_assoc())
    197197  {
    198198    $DefinitionItems = array();
     
    308308function ShowViewItem($List, $Id,  $Column = '', $ColumnValue = 0)
    309309{
    310   global $Database, $Types, $Lists;
     310  global $Database, $Types;
    311311
    312312  if(!CheckPermission('Read', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
    313313  $Output = '';
    314314  $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1');
    315   while($DbRow = $DbResult->fetch_array())
     315  while($DbRow = $DbResult->fetch_assoc())
    316316  {
    317317    $DefinitionItems = array();
     
    346346      if($Types[$Item['Type']]['BaseType'] == 'PointerOneToMany')
    347347      {
    348         $SubList = $Lists[$Types[$Item['Type']]['Parameters'][0]];
     348        $SubList = GetListDefinition($Types[$Item['Type']]['Parameters'][0]);
    349349        $Output .= ShowList($SubList, $Types[$Item['Type']]['Parameters'][1], $DbRow['ItemId'], $Item['TextBefore']).'<br /><br />';
    350350      }
     
    356356function ShowDeleteItem($List, $Id)
    357357{
    358   global $Database, $Lists, $System, $LogActionType;
     358  global $Database, $System, $LogActionType;
    359359
    360360  if(!CheckPermission('Write', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
     
    362362  $System->Modules['DatabaseList']->DeleteItem($List['TableName'], $Id);
    363363  $Output = 'Položka smazána.';
    364   $Output .= ShowList($Lists[$_SESSION['Table']], $Lists[$_SESSION['Column']], $Lists[$_SESSION['ColumnValue']]).'<br /><br />';
     364  $Output .= ShowList($_SESSION['Table'], $_SESSION['Column'], $_SESSION['ColumnValue']).'<br /><br />';
    365365  ExecuteListEvent($List['TableName'], 'OnDelete', $Id);
    366366  return($Output);
     
    369369function ShowMenu()
    370370{
    371   global $Lists, $Database;
     371  global $Database;
    372372
    373373  $Output = '';
     
    391391function Output()
    392392{
    393   global $Lists;
    394 
    395393  $PermanentVar = array('Table', 'Item', 'Column', 'ColumnValue', 'Action');
    396394  if($_GET['Table'] != $_SESSION['Table'])
     
    404402  }
    405403  $Output = '';
    406   if(array_key_exists('Table', $_SESSION) and array_key_exists($_SESSION['Table'], $Lists))
    407   {
    408     $List = $Lists[$_SESSION['Table']];
     404  if(array_key_exists('Table', $_SESSION))
     405  {
     406    $List = GetListDefinition($_SESSION['Table']);
    409407    if(array_key_exists('Action', $_SESSION))
    410408    {
     
    441439}
    442440
    443 function LoadListDefinition()
     441function GetListDefinition($Id)
    444442{
    445443  global $Database, $Lists;
    446444
    447   $DbResult = $Database->query('SELECT t1.* FROM `SystemList` AS t1 LEFT JOIN `SystemList` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL)');
    448   while($DbRow = $DbResult->fetch_assoc())
    449   {
    450     $Items = array();
    451     $DbResult2 = $Database->query('SELECT t1.* FROM `SystemListItem` AS t1 LEFT JOIN `SystemListItem` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND (t1.List='.$DbRow['ItemId'].')');
    452     while($DbRow2 = $DbResult2->fetch_assoc())
    453     {
    454       $Items[$DbRow2['Name']] = $DbRow2;
    455     }
    456     $List = array(
    457      'Id' => $DbRow['Id'],
    458      'ItemId' => $DbRow['ItemId'],
    459      'TableName' => $DbRow['TableName'],
    460      'Title' => $DbRow['Title'],
    461      'Items' => $Items,
    462     );
    463     $Lists[$List['TableName']] = $List;
    464   }
     445  if(!array_key_exists($Id, $Lists))
     446  {
     447    $DbResult = $Database->query('SELECT t1.* FROM `SystemList` AS t1 LEFT JOIN `SystemList` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND t1.TableName="'.$Id.'"');
     448    if($DbResult->num_rows > 0)
     449    {
     450      $DbRow = $DbResult->fetch_assoc();
     451      $Items = array();
     452      $DbResult2 = $Database->query('SELECT t1.* FROM `SystemListItem` AS t1 LEFT JOIN `SystemListItem` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND (t1.List='.$DbRow['ItemId'].')');
     453      while($DbRow2 = $DbResult2->fetch_assoc())
     454      {
     455        $Items[$DbRow2['Name']] = $DbRow2;
     456      }
     457      $List = array(
     458       'Id' => $DbRow['Id'],
     459       'ItemId' => $DbRow['ItemId'],
     460       'TableName' => $DbRow['TableName'],
     461       'Title' => $DbRow['Title'],
     462       'Items' => $Items,
     463      );
     464      $Lists[$List['TableName']] = $List;
     465    } else $Lists[$List['TableName']] = NULL;
     466  }
     467  return($Lists[$Id]);
    465468  //print_r($Lists);
    466469}
  • forms.php

    r19 r20  
    9898
    9999    $DbResult = $Database->query('SELECT * FROM '.$this->Definition['Table'].' WHERE Id='.$Id);
    100     $DbRow = $DbResult->fetch_array();
     100    $DbRow = $DbResult->fetch_assoc();
    101101    foreach($this->Definition['Items'] as $Item)
    102102    {
  • global.php

    r19 r20  
    5050$System->Modules['User']->Check();
    5151LoadTypeDefinition();
    52 LoadListDefinition();
    5352
    5453$MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
  • types/PointerOneToOne.php

    r19 r20  
    55  function GetTablePointerName($Type, $Item)
    66  {
    7     global $Database, $Lists;
     7    global $Database;
    88
    99    //print_r($Item);
     
    1111    $TargetTable = $Type['Parameters'][0];
    1212
    13     foreach($Lists[$TargetTable]['Items'] as $ListItem)
     13    $List = GetListDefinition($TargetTable);
     14    foreach($List['Items'] as $ListItem)
    1415      if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
    1516    $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, ItemId, Id';
     
    2425  function GetTablePointerNameList($Type, $Item)
    2526  {
    26     global $Database, $Lists;
     27    global $Database;
    2728
    2829    $Columns = '';
    2930    $TargetTable = $Type['Parameters'][0];
    3031
    31     foreach($Lists[$TargetTable]['Items'] as $ListItem)
     32    $List = GetListDefinition($TargetTable);
     33    foreach($List['Items'] as $ListItem)
    3234      if($ListItem['VisibleInPointer'] == 1) $Columns .= 't1.`'.$ListItem['Name'].'`," ",';
    3335    $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, t1.Id, t1.ItemId, t1.DeletionTime';
     
    4547  function OnView($Item)
    4648  {
    47     global $Database, $Lists, $Types;
     49    global $Database, $Types;
    4850
    4951    $Type = $Types[$Item['Type']];
     
    5658  function OnEdit($Item)
    5759  {
    58     global $Database, $Lists, $Types;
     60    global $Database, $Types;
    5961
    6062    $Type = $Types[$Item['Type']];
  • user.php

    r18 r20  
    5151    // Zkontroluj přihlášení
    5252    $Query = $this->Database->select($this->TableUserOnline, '*', 'SessionId="'.$SID.'"');
    53     $Row = $Query->fetch_array();
     53    $Row = $Query->fetch_assoc();
    5454    if($Row['User'] != 0)
    5555    {
     
    115115    if($DbResult->num_rows > 0)
    116116    {
    117       $Row = $DbResult->fetch_array();
     117      $Row = $DbResult->fetch_assoc();
    118118      if($Hash == $Row['Password'])
    119119      {
     
    133133    if($Query->num_rows > 0)
    134134    {
    135       $Row = $Query->fetch_array();
     135      $Row = $Query->fetch_assoc();
    136136      if($Row['Password'] != $Password) $Result = BAD_PASSWORD;
    137137      else if($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;
     
    167167    if($DbResult->num_rows > 0)
    168168    {
    169       $Row = $DbResult->fetch_array();
     169      $Row = $DbResult->fetch_assoc();
    170170      $NewPassword = substr(sha1(strtoupper($Row['Name'])), 0, 7);
    171171
     
    185185    if($DbResult->num_rows > 0)
    186186    {
    187       $Row = $DbResult->fetch_array();
     187      $Row = $DbResult->fetch_assoc();
    188188      $NewPassword2 = substr(sha1(strtoupper($Row['Name'])), 0, 7);
    189189      if(($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))
Note: See TracChangeset for help on using the changeset viewer.