Changeset 606 for trunk/admin


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
Location:
trunk/admin
Files:
5 edited

Legend:

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

    r597 r606  
    785785  }
    786786}
     787
     788/**
     789 * inserts multiple lines in a table
     790 *
     791 * @param string table_name
     792 * @param array dbields
     793 * @param array inserts
     794 * @return void
     795 */
     796function mass_inserts($table_name, $dbfields, $inserts)
     797{
     798  // inserts all found categories
     799  $query = '
     800INSERT INTO '.$table_name.'
     801  ('.implode(',', $dbfields).')
     802   VALUES';
     803  foreach ($inserts as $insert_id => $insert)
     804  {
     805    $query.= '
     806  ';
     807    if ($insert_id > 0)
     808    {
     809      $query.= ',';
     810    }
     811    $query.= '(';
     812    foreach ($dbfields as $field_id => $dbfield)
     813    {
     814      if ($field_id > 0)
     815      {
     816        $query.= ',';
     817      }
     818     
     819      if (!isset($insert[$dbfield]) or $insert[$dbfield] == '')
     820      {
     821        $query.= 'NULL';
     822      }
     823      else
     824      {
     825        $query.= "'".$insert[$dbfield]."'";
     826      }
     827    }
     828    $query.=')';
     829  }
     830  $query.= '
     831;';
     832  pwg_query($query);
     833}
    787834?>
  • trunk/admin/infos_images.php

    r593 r606  
    320320  while ($row = mysql_fetch_array($result))
    321321  {
    322     $thumbnail_url = get_thumbnail_src($row['file'],
    323                                        $row['storage_category_id'],
    324                                        @$row['tn_ext']);
     322    $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
    325323
    326324    $template->assign_block_vars(
  • trunk/admin/picture_modify.php

    r593 r606  
    200200$dir_path = get_cat_display_name($current_category['name'], '->', '');
    201201
    202 $thumbnail_url = get_thumbnail_src($row['file'],
    203                                    $row['storage_category_id'],
    204                                    @$row['tn_ext']);
     202$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
    205203
    206204$url_img = PHPWG_ROOT_PATH.'picture.php?image_id='.$_GET['image_id'];
  • trunk/admin/remote_site.php

    r602 r606  
    110110
    111111  return $database_dirs;
    112 }
    113 
    114 /**
    115  * inserts multiple lines in a table
    116  *
    117  * @param string table_name
    118  * @param array dbields
    119  * @param array inserts
    120  * @return void
    121  */
    122 function mass_inserts($table_name, $dbfields, $inserts)
    123 {
    124   // inserts all found categories
    125   $query = '
    126 INSERT INTO '.$table_name.'
    127   ('.implode(',', $dbfields).')
    128    VALUES';
    129   foreach ($inserts as $insert_id => $insert)
    130   {
    131     $query.= '
    132   ';
    133     if ($insert_id > 0)
    134     {
    135       $query.= ',';
    136     }
    137     $query.= '(';
    138     foreach ($dbfields as $field_id => $dbfield)
    139     {
    140       if ($field_id > 0)
    141       {
    142         $query.= ',';
    143       }
    144      
    145       if (!isset($insert[$dbfield]) or $insert[$dbfield] == '')
    146       {
    147         $query.= 'NULL';
    148       }
    149       else
    150       {
    151         $query.= "'".$insert[$dbfield]."'";
    152       }
    153     }
    154     $query.=')';
    155   }
    156   $query.= '
    157 ;';
    158   pwg_query($query);
    159112}
    160113
     
    419372                             'keywords',
    420373                             'name',
    421                              'comment');
     374                             'comment',
     375                             'path');
    422376      foreach ($optional_atts as $att)
    423377      {
     
    435389    $dbfields = array('file','storage_category_id','date_available','tn_ext',
    436390                      'filesize','width','height','date_creation','author',
    437                       'keywords','name','comment');
     391                      'keywords','name','comment','path');
    438392    mass_inserts(IMAGES_TABLE, $dbfields, $inserts);
    439393    $counts{'new_elements'}+= count($inserts);
  • 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.