Index: include/export.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- include/export.php (revision ) +++ include/export.php (revision ) @@ -57,6 +57,8 @@ # URL of the file with log of export $export_log_url = "get_log.php?file=".$export_log_filename; +$parent_range_cache = array(); + # # Get export sections tree # @@ -490,6 +492,7 @@ # function func_export_get_row($res) { global $section, $import_specification, $parent_range_query, $sql_tbl; + global $parent_range_cache; if (!$res) return false; @@ -526,6 +529,9 @@ # Define SQL query (get parent section ID by current section ID) $query = "SELECT ".$sql_tbl[$import_specification[$parent_range_query['section']]['table']].".".$import_specification[$parent_range_query['section']]['key_field']." FROM ".$sql_tbl[$import_specification[$parent_range_query['section']]['table']].", ".implode(", ", $for)." WHERE ".$sql_tbl[$import_specification[$parent_range_query['section']]['table']].".".$import_specification[$parent_range_query['section']]['key_field']." = ".$last_key." AND ".implode(" AND ", $where); + if(empty($parent_range_cache[$section]) && !empty($parent_range_query['query'])){ + $parent_range_cache[$section] = func_query_column($parent_range_query['query']); + } while ($row !== false) { $row = array_shift($row); @@ -536,14 +542,10 @@ if (!empty($ids)) { # Check defined parent section IDs - $tmp = db_query($parent_range_query['query']); - if ($tmp) { - while ($id = db_fetch_array($tmp)) { - $id = array_shift($id); - if (in_array($id, $ids)) + foreach($ids as $id) { + if (in_array($id, $parent_range_cache[$section])){ - return $row; + return $row; } - db_free_result($tmp); } } @@ -652,7 +654,7 @@ # Return full image path (URL) if image stored as URL return $v['image_path']; - + } return false;