/**
  * Correct references in configuration
  */
 private function correctConfigReferences()
 {
     if (isset($_POST['overwrite_config'])) {
         $ConfigValues = Configuration\Handle::tableHandles();
         foreach ($ConfigValues as $key => $table) {
             $table = 'runalyze_' . $table;
             if (isset($this->ReplaceIDs[$table])) {
                 $OldValue = $this->DB->query('SELECT `value` FROM `' . PREFIX . 'conf` WHERE `key`="' . $key . '" LIMIT 1')->fetchColumn();
                 $NewValue = $this->correctID($table, $OldValue);
                 if ($NewValue != 0) {
                     $this->DB->updateWhere('conf', '`key`="' . $key . '"', 'value', $NewValue);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @covers PDOforRunalyze::insert
  * @covers PDOforRunalyze::update
  * @covers PDOforRunalyze::updateWhere
  * @covers PDOforRunalyze::exec
  */
 public function testUpdate()
 {
     $this->object->insert('training', array('id', 's', 'distance'), array(1, 600, 1));
     $this->object->insert('training', array('id', 's', 'distance'), array(2, 900, 1));
     $this->object->insert('training', array('id', 's', 'distance'), array(3, 300, 1));
     $this->object->update('training', 1, 'distance', 2);
     $this->assertEquals(array(600, 2), $this->object->query('SELECT `s`, `distance` FROM `runalyze_training` WHERE `id`=1 LIMIT 1')->fetch(PDO::FETCH_NUM));
     $this->object->update('training', 2, 'distance', 3);
     $this->assertEquals(array(900, 3), $this->object->query('SELECT `s`, `distance` FROM `runalyze_training` WHERE `id`=2 LIMIT 1')->fetch(PDO::FETCH_NUM));
     $this->object->update('training', 3, array('s', 'distance'), array(150, 0.5));
     $this->assertEquals(array(150, 0.5), $this->object->query('SELECT `s`, `distance` FROM `runalyze_training` WHERE `id`=3 LIMIT 1')->fetch(PDO::FETCH_NUM));
     $this->object->updateWhere('training', '`distance` > 1', 'comment', 'Super weit.');
     $this->assertEquals("1,2", $this->object->query('SELECT GROUP_CONCAT(`id`) FROM `runalyze_training` WHERE `comment`="Super weit." GROUP BY `accountid`')->fetchColumn());
     $this->assertEquals(3, $this->object->exec('DELETE FROM `runalyze_training`'));
     $this->assertEquals(0, $this->object->query('SELECT COUNT(*) FROM `runalyze_training`')->fetchColumn());
     $this->object->exec('TRUNCATE TABLE `runalyze_training`');
 }