public function getUncompletedMatchen() { $matchen = array(); $now = time(); require 'conexie.php'; $sql = "SELECT `uid`,`mid`,`cid` FROM `matchen` WHERE `completed` = '0' AND `ts` < '" . $now . "' ORDER BY `cid`"; $result = mysqli_query($db, $sql) or die("<error>Query on database competities does not work.</error>"); $cids_to_update = array(); $current_cid = 0; $cids_num = 0; $update_sqls = array(); $results = array(); while ($row = mysqli_fetch_object($result)) { $info = array("uid" => $row->uid, "mid" => $row->mid); if ($current_cid !== $row->cid) { $cids_to_update[] = array("cid" => $row->cid, "info" => array($info)); $current_cid = $row->cid; $cids_num++; } else { $cids_to_update[$cids_num]['info'][] = $info; } } // cid info ophalen foreach ($cids_to_update as $cid_to_update) { $current_cid = $cid_to_update['cid']; $sql = "SELECT `id`,`draw` FROM `competities` WHERE `cid` = '" . $current_cid . "' LIMIT 1"; $result = mysqli_query($db, $sql) or die("<error>Query on database competities does not work.</error>"); // get ID and DRAW while ($row = mysqli_fetch_object($result)) { $cid_to_update['id'] = $row->id; $cid_to_update['draw'] = $row->draw; $cc = new CompetitionCreator($row->id, $row->draw); $s1 = $cc->createCompetition(); $results[] = $s1; $s2 = $cc->createMatches(); $results[] = $s2; $s3 = $cc->createTeams(); $results[] = $s3; } } // results? header('Content-type: text/xml'); echo '<results>'; for ($i = 0; $i < count($results); $i++) { echo $results[$i]; } echo '</results>'; }
$_ID = ""; $_DRAW = ""; $_ID = $_GET['id']; $_DRAW = $_GET['draw']; // default waarden (om altijd geldig resultaat te hebben) if ($_ID == "") { $_ID = 'B2DF27E6-FEEC-4C30-9A52-7BED76544B48'; $_DRAW = '3'; } // Create new competition $cc = new CompetitionCreator($_ID, $_DRAW); $results = array(); $s1 = $cc->createCompetition(); $results[] = $s1; $s2 = $cc->createMatches(); $results[] = $s2; $s3 = $cc->createTeams(); $results[] = $s3; // return value? //print_r($success); //echo($xml); //header ('Content-type: text/xml'); $xml_output = ''; $xml_output .= '<results>'; for ($i = 0; $i < count($results); $i++) { //$xml = simplexml_load_string($results[$i]); //echo $xml; $xml_output .= $results[$i]; } $xml_output .= '</results>'; echo $xml_output;