protected function setUp() { \Cache::clean(); $this->PDO = \DB::getInstance(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'sport` (`name`,`kcal`,`outside`,`accountid`,`power`) VALUES("",600,1,0,1)'); $this->OutdoorID = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'sport` (`name`,`kcal`,`outside`,`accountid`,`power`) VALUES("",400,0,0,0)'); $this->IndoorID = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'shoe` (`name`,`km`,`time`,`accountid`) VALUES("",10,3000,0)'); $this->ShoeID1 = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'shoe` (`name`,`km`,`time`,`accountid`) VALUES("",0,0,0)'); $this->ShoeID2 = $this->PDO->lastInsertId(); \SportFactory::reInitAllSports(); \ShoeFactory::reInitAllShoes(); }
protected function setUp() { \Cache::clean(); $this->PDO = \DB::getInstance(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'sport` (`name`,`kcal`,`outside`,`accountid`,`power`,`HFavg`) VALUES("",600,1,0,1,160)'); $this->OutdoorID = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'sport` (`name`,`kcal`,`outside`,`accountid`,`power`,`HFavg`) VALUES("",400,0,0,0,100)'); $this->IndoorID = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'equipment_type` (`name`,`accountid`) VALUES("Type",0)'); $this->EquipmentType = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'equipment_sport` (`sportid`,`equipment_typeid`) VALUES(' . $this->OutdoorID . ',' . $this->EquipmentType . ')'); $this->PDO->exec('INSERT INTO `' . PREFIX . 'equipment` (`name`,`typeid`,`notes`,`accountid`) VALUES("A",' . $this->EquipmentType . ',"",0)'); $this->EquipmentA = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'equipment` (`name`,`typeid`,`notes`,`accountid`) VALUES("B",' . $this->EquipmentType . ',"",0)'); $this->EquipmentB = $this->PDO->lastInsertId(); $Factory = new Model\Factory(0); $Factory->clearCache('sport'); \SportFactory::reInitAllSports(); }
/** * Parse all post values */ public function parsePostData() { $Sports = SportFactory::AllSports(); $Sports[] = array('id' => -1); foreach ($Sports as $Data) { $id = $Data['id']; $columns = array('name', 'img', 'short', 'kcal', 'HFavg', 'distances', 'speed', 'power', 'outside', 'main_equipmenttypeid'); $values = array($_POST['sport']['name'][$id], $_POST['sport']['img'][$id], $_POST['sport']['short'][$id], $_POST['sport']['kcal'][$id], $_POST['sport']['HFavg'][$id], isset($_POST['sport']['distances'][$id]), $_POST['sport']['speed'][$id], isset($_POST['sport']['power'][$id]), isset($_POST['sport']['outside'][$id]), $_POST['sport']['main_equipmenttypeid'][$id]); if (isset($_POST['sport']['delete'][$id]) && $id != Runalyze\Configuration::General()->runningSport()) { DB::getInstance()->deleteByID('sport', (int) $id); } elseif ($Data['id'] != -1) { DB::getInstance()->update('sport', $id, $columns, $values); } elseif (strlen($_POST['sport']['name'][$id]) > 2) { Db::getInstance()->insert('sport', $columns, $values); } } SportFactory::reInitAllSports(); Ajax::setReloadFlag(Ajax::$RELOAD_DATABROWSER); }