Ignore:
Timestamp:
May 6, 2008, 3:04:58 AM (16 years ago)
Author:
rvelices
Message:
  • remove some unnecessary db columns (#history_summary.id, #history.year, month, day and hour)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r2325 r2333  
    278278    $where_cats = '%s IN('.wordwrap(implode(', ', $ids), 120, "\n").')';
    279279  }
    280  
     280
    281281  // find all categories where the setted representative is not possible :
    282282  // the picture does not exist
     
    395395      {
    396396        $query = '
    397   INSERT INTO '.$table_name.'
    398     ('.implode(',', $dbfields).')
    399      VALUES';
     397INSERT INTO '.$table_name.'
     398  ('.implode(',', $dbfields).')
     399  VALUES';
    400400        $first = false;
    401401      }
     
    403403      {
    404404        $query .= '
    405     , ';
     405  , ';
    406406      }
    407407
     
    453453      {
    454454        $query = '
    455   UPDATE '.$tablename.'
    456     SET ';
     455UPDATE '.$tablename.'
     456  SET ';
    457457        $is_first = true;
    458458        foreach ($dbfields['update'] as $key)
     
    474474        }
    475475        $query.= '
    476     WHERE ';
     476  WHERE ';
    477477
    478478        $is_first = true;
     
    483483            $query.= ' AND ';
    484484          }
    485           $query.= $key.' = \''.$data[$key].'\'';
     485          if ( isset($data[$key]) )
     486          {
     487            $query.= $key.' = \''.$data[$key].'\'';
     488          }
     489          else
     490          {
     491            $query.= $key.' IS NULL';
     492          }
    486493          $is_first = false;
    487494        }
    488495        $query.= '
    489   ;';
     496;';
    490497        pwg_query($query);
    491498      }
     
    495502      // creation of the temporary table
    496503      $query = '
    497   SHOW FULL COLUMNS FROM '.$tablename.'
     504SHOW FULL COLUMNS FROM '.$tablename.'
    498505;';
    499506      $result = pwg_query($query);
     
    506513          $column = $row['Field'];
    507514          $column.= ' '.$row['Type'];
    508           if (!isset($row['Null']) or $row['Null'] == '')
     515
     516          $nullable = true;
     517          if (!isset($row['Null']) or $row['Null'] == '' or $row['Null']=='NO')
    509518          {
    510519            $column.= ' NOT NULL';
     520            $nullable = false;
    511521          }
    512522          if (isset($row['Default']))
    513523          {
    514524            $column.= " default '".$row['Default']."'";
     525          }
     526          elseif ($nullable)
     527          {
     528            $column.= " default NULL";
    515529          }
    516530          if (isset($row['Collation']) and $row['Collation'] != 'NULL')
     
    528542  (
    529543  '.implode(",\n", $columns).',
    530   PRIMARY KEY ('.implode(',', $dbfields['primary']).')
     544  UNIQUE KEY the_key ('.implode(',', $dbfields['primary']).')
    531545  )
    532546;';
     547
    533548      pwg_query($query);
    534549      mass_inserts($temporary_tablename, $all_fields, $datas);
    535550      // update of images table by joining with temporary table
    536551      $query = '
    537   UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2
    538     SET '.
     552UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2
     553  SET '.
    539554        implode(
    540555          "\n    , ",
     
    544559            )
    545560          ).'
    546     WHERE '.
     561  WHERE '.
    547562        implode(
    548563          "\n    AND ",
     
    555570      pwg_query($query);
    556571      $query = '
    557   DROP TABLE '.$temporary_tablename.'
     572DROP TABLE '.$temporary_tablename.'
    558573;';
    559574      pwg_query($query);
Note: See TracChangeset for help on using the changeset viewer.