Changeset 606 for trunk/admin/update.php


Ignore:
Timestamp:
Nov 17, 2004, 12:38:34 AM (20 years ago)
Author:
plg
Message:
  • images.path column added to reduce database access
  • function mass_inserts moved from admin/remote_sites.php to admin/include/function.php
  • function mass_inserts used in admin/update.php
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/update.php

    r602 r606  
    3232include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
    3333
    34 define('CURRENT_DATE', "'".date('Y-m-d')."'");
     34define('CURRENT_DATE', date('Y-m-d'));
    3535// +-----------------------------------------------------------------------+
    3636// |                              functions                                |
     
    408408        {
    409409          $insert = array();
    410           $insert['file'] = "'".$unregistered_element."'";
     410          $insert['file'] = $unregistered_element;
    411411          $insert['storage_category_id'] = $category_id;
    412412          $insert['date_available'] = CURRENT_DATE;
    413           $insert['tn_ext'] = "'".$tn_ext."'";
     413          $insert['tn_ext'] = $tn_ext;
     414          $insert['path'] = $dir.$unregistered_element;
    414415
    415416          $counts['new_elements']++;
     
    447448
    448449        $insert = array();
    449         $insert['file'] = "'".$unregistered_element."'";
     450        $insert['file'] = $unregistered_element;
     451        $insert['path'] = $dir.$unregistered_element;
    450452        $insert['storage_category_id'] = $category_id;
    451453        $insert['date_available'] = CURRENT_DATE;
    452454        if ( $tn_ext != '' )
    453455        {
    454           $insert['tn_ext'] = "'".$tn_ext."'";
     456          $insert['tn_ext'] = $tn_ext;
    455457        }
    456458        if ( $representative_ext != '' )
    457459        {
    458           $insert['representative_ext'] = "'".$representative_ext."'";
     460          $insert['representative_ext'] = $representative_ext;
    459461        }
    460462
     
    476478    $dbfields = array(
    477479      'file','storage_category_id','date_available','tn_ext'
    478       ,'representative_ext'
     480      ,'representative_ext','path'
    479481      );
    480     $query = '
    481 INSERT INTO '.IMAGES_TABLE.'
    482   ('.implode(',', $dbfields).')
    483    VALUES
    484    ';
    485     foreach ($inserts as $insert_id => $insert)
    486     {
    487       $query.= '
    488 ';
    489       if ($insert_id > 0)
    490       {
    491         $query.= ',';
    492       }
    493       $query.= '(';
    494       foreach ($dbfields as $field_id => $dbfield)
    495       {
    496         if ($field_id > 0)
    497         {
    498           $query.= ',';
    499         }
    500        
    501         if (!isset($insert[$dbfield]) or $insert[$dbfield] == '')
    502         {
    503           $query.= 'NULL';
    504         }
    505         else
    506         {
    507           $query.= $insert[$dbfield];
    508         }
    509       }
    510       $query.=')';
    511     }
    512     $query.= '
    513 ;';
    514 
    515     pwg_query($query);
     482    mass_inserts(IMAGES_TABLE, $dbfields, $inserts);
    516483
    517484    // what are the ids of the pictures in the $category_id ?
Note: See TracChangeset for help on using the changeset viewer.