Index: trunk/core/kernel/utility/temp_handler.php =================================================================== diff -u -r2791 -r2792 --- trunk/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 2791) +++ trunk/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 2792) @@ -99,8 +99,9 @@ function CreateTempTable($table) { $query = sprintf("CREATE TABLE %s SELECT * FROM %s WHERE 0", - $this->GetTempName($table), - $table); + $this->GetTempName($table), + $table); + $this->Conn->Query($query); } @@ -139,20 +140,11 @@ $SubItems = $this->Application->getUnitOption($prefix,'SubItems'); $same_sub_counter = 1; - if (is_array($SubItems)) { - foreach ($SubItems as $prefix) { - if (preg_match("/^SAME:(.*)/", $prefix, $regs)) { - $same_sub = $tmp; - $same_sub['Prefix'] = $tmp['Prefix'].'.'.$same_sub_counter; - $same_sub['Constrain'] = $regs[1]; - $same_sub['ParentTableKey'] = $tmp['IdField']; - $same_sub['ForeignKey'] = $this->Application->getUnitOption($tmp['Prefix'],'ForeignKey'.$same_sub_counter); - $tmp['SubTables'][] = $same_sub; - $same_sub_counter++; - } - else { - $this->AddTables($prefix, $tmp); - } + if( is_array($SubItems) ) + { + foreach($SubItems as $prefix) + { + $this->AddTables($prefix, $tmp); } } @@ -293,8 +285,10 @@ // the table will be first copied by first sub-table, then dropped and copied over by last ForeignKey in the array // this should not do any problems :) if ( !preg_match("/.*\.[0-9]+/", $master['Prefix']) ) { - $this->DropTempTable($master['TableName']); - $this->CreateTempTable($master['TableName']); + if( $this->DropTempTable($master['TableName']) ) + { + $this->CreateTempTable($master['TableName']); + } } if (is_array($ids)) { @@ -552,12 +546,14 @@ function DropTempTable($table) { - if (in_array($table, $this->DroppedTables)) return; + if( in_array($table, $this->DroppedTables) ) return false; $query = sprintf("DROP TABLE IF EXISTS %s", $this->GetTempName($table) ); - $this->DroppedTables = array_unique(array_push($this->DroppedTables, $table)); + array_push($this->DroppedTables, $table); + $this->DroppedTables = array_unique($this->DroppedTables); $this->Conn->Query($query); + return true; } function PrepareEdit()