Exemplo n.º 1
0
 /**
  * Run backup
  */
 public final function run()
 {
     $this->DB->stopAddingAccountID();
     $Tables = array(PREFIX . 'account', PREFIX . 'clothes', PREFIX . 'conf', PREFIX . 'dataset', PREFIX . 'hrv', PREFIX . 'plugin', PREFIX . 'plugin_conf', PREFIX . 'shoe', PREFIX . 'sport', PREFIX . 'type', PREFIX . 'user', PREFIX . 'route', PREFIX . 'training', PREFIX . 'trackdata', PREFIX . 'swimdata');
     foreach ($Tables as $TableName) {
         $this->saveTableStructure($TableName);
         $this->saveTableRows($TableName);
     }
     $this->Writer->finish();
     $this->DB->startAddingAccountID();
 }
Exemplo n.º 2
0
 /**
  * @covers PDOforRunalyze::startAddingAccountID
  * @covers PDOforRunalyze::stopAddingAccountID
  * @covers PDOforRunalyze::setAccountID
  */
 public function testStartAddingAccountID()
 {
     $this->object->exec('INSERT INTO `runalyze_training` (`s`, `accountid`) VALUES(100, 1)');
     $this->object->exec('INSERT INTO `runalyze_training` (`s`, `accountid`) VALUES(200, 1)');
     $this->object->exec('INSERT INTO `runalyze_training` (`s`, `accountid`) VALUES(66, 3)');
     $this->object->setAccountID(1);
     $this->object->startAddingAccountID();
     $this->assertEquals(300, $this->object->query('SELECT SUM(`s`) FROM `runalyze_training`')->fetchColumn());
     $this->assertEquals(2, $this->object->query('SELECT COUNT(*) FROM `runalyze_training`')->fetchColumn());
     $this->object->setAccountID(3);
     $this->assertEquals(66, $this->object->query('SELECT SUM(`s`) FROM `runalyze_training`')->fetchColumn());
     $this->assertEquals(1, $this->object->query('SELECT COUNT(*) FROM `runalyze_training`')->fetchColumn());
     $this->object->stopAddingAccountID();
     $this->assertEquals(366, $this->object->query('SELECT SUM(`s`) FROM `runalyze_training`')->fetchColumn());
     $this->assertEquals(3, $this->object->query('SELECT COUNT(*) FROM `runalyze_training`')->fetchColumn());
     $this->object->exec('TRUNCATE TABLE `runalyze_training`');
     $this->object->setAccountID(false);
 }
Exemplo n.º 3
0
 /**
  * Run backup
  */
 public final function run()
 {
     $this->DB->stopAddingAccountID();
     $this->startBackup();
     // REMINDER: think about required order, e.g.
     // - plugin before plugin_conf
     // - sport/type/route before training
     // - training before trackdata/swimdata/hrv
     // - equipment_Type before equipment_sport before equipment before activity_equipment
     // - tag before activity_tag
     $Tables = array(PREFIX . 'account', PREFIX . 'conf', PREFIX . 'dataset', PREFIX . 'plugin', PREFIX . 'plugin_conf', PREFIX . 'sport', PREFIX . 'type', PREFIX . 'user', PREFIX . 'route', PREFIX . 'training', PREFIX . 'trackdata', PREFIX . 'swimdata', PREFIX . 'hrv', PREFIX . 'equipment_type', PREFIX . 'equipment_sport', PREFIX . 'equipment', PREFIX . 'activity_equipment', PREFIX . 'tag', PREFIX . 'activity_tag');
     foreach ($Tables as $TableName) {
         $this->saveTableStructure($TableName);
         $this->saveTableRows($TableName);
     }
     $this->finishBackup();
     $this->Writer->finish();
     $this->DB->startAddingAccountID();
 }