/**
  * Import table
  * @param string $TableName
  */
 private function importTable($TableName)
 {
     $Line = $this->Reader->readLine();
     if ($Line[0] != '{') {
         return;
     }
     $CompleteRow = json_decode($Line, true);
     $Row = array_shift($CompleteRow);
     $Columns = array_keys($Row);
     $BulkInsert = new RunalyzeBulkInsert($TableName, $Columns, $this->AccountID);
     while ($Line[0] == '{') {
         $CompleteRow = json_decode($Line, true);
         $ID = key($CompleteRow);
         $Row = current($CompleteRow);
         $Values = array_values($Row);
         if ($Columns[0] == 'name' || $TableName == 'runalyze_plugin') {
             if (isset($this->ExistingData[$TableName][$Values[0]])) {
                 $this->ReplaceIDs[$TableName][$ID] = $this->ExistingData[$TableName][$Values[0]];
             } else {
                 $this->ReplaceIDs[$TableName][$ID] = $BulkInsert->insert($Values);
                 $this->Results->addInserts($TableName, 1);
             }
         } else {
             $this->correctValues($TableName, $Row);
             if ($TableName == 'runalyze_training') {
                 $this->ReplaceIDs[$TableName][$ID] = $BulkInsert->insert(array_values($Row));
             } else {
                 $BulkInsert->insert(array_values($Row));
             }
             $this->Results->addInserts($TableName, 1);
         }
         $Line = $this->Reader->readLine();
     }
 }
 /**
  * Import table
  * @param string $TableName
  */
 private function importTable($TableName)
 {
     $Line = $this->Reader->readLine();
     if ($Line[0] != '{') {
         return;
     }
     $CompleteRow = json_decode($Line, true);
     $Row = array_shift($CompleteRow);
     $Columns = array_keys($Row);
     $BulkInsert = new RunalyzeBulkInsert($TableName, $Columns, $this->AccountID);
     while ($Line[0] == '{') {
         $CompleteRow = json_decode($Line, true);
         $ID = key($CompleteRow);
         $Row = current($CompleteRow);
         $Values = array_values($Row);
         if (in_array($TableName, array('runalyze_equipment', 'runalyze_equipment_type', 'runalyze_plugin', 'runalyze_route', 'runalyze_sport', 'runalyze_type', 'runalyze_tag'))) {
             if (isset($this->ExistingData[$TableName][$Values[0]])) {
                 $this->ReplaceIDs[$TableName][$ID] = $this->ExistingData[$TableName][$Values[0]];
             } else {
                 $this->correctValues($TableName, $Row);
                 $this->ReplaceIDs[$TableName][$ID] = $BulkInsert->insert(array_values($Row));
                 $this->Results->addInserts($TableName, 1);
             }
         } elseif ($TableName == 'runalyze_equipment_sport' && $this->equipmentSportRelationDoesExist($Row['sportid'], $Row['equipment_typeid'])) {
             // Hint: Don't insert this relation, it does exist already!
         } else {
             $this->correctValues($TableName, $Row);
             if ($TableName == 'runalyze_training') {
                 $this->ReplaceIDs[$TableName][$ID] = $BulkInsert->insert(array_values($Row));
             } else {
                 $BulkInsert->insert(array_values($Row));
             }
             $this->Results->addInserts($TableName, 1);
         }
         $Line = $this->Reader->readLine();
     }
 }