<body> <h1> Table Gateways Tester </h1> <?php echo '<hr/>'; echo '<h2>Test BrowserTableGateway</h2>'; echo '<h3>Test findAll()</h3>'; $gate = new BrowserTableGateway($dbAdapter); $result = $gate->findAll(); foreach ($result as $row) { echo $row->id . " - " . $row->name . "<br/>"; } echo '<h3>Test findById(3)</h3>'; $gate = new VisitsTableGateway($dbAdapter); $result = $gate->findByBrowserPercent(); foreach ($result as $row) { echo "['" . $row->name . "', " . $row->num . "],"; } echo '<hr/>'; echo '<h2>Test DeviceBrandTableGateway</h2>'; echo '<h3>Test findAllSorted()</h3>'; $gate = new DeviceBrandTableGateway($dbAdapter); $result = $gate->findAllSorted(true); foreach ($result as $row) { echo $row->id . " - " . $row->name . "<br/>"; } echo '<h3>Test findById(11)</h3>'; $result = $gate->findById(11); echo $result->id . " - " . $result->name; // all done close connection $dbAdapter->closeConnection();
foreach ($results as $result) { $browserVisits[$result->name] = $visitsGateway->countByBrowser($result->id); $totalVisits += $browserVisits[$result->name]; } foreach ($browserVisits as $key => $value) { $browserVisits[$key] = round($value / $totalVisits * 100, 2) . "%"; } $browserHeaders = array("Browser", "Visits"); /* * Retrieves all visit information for a specific brand */ $brandsGateway = new DeviceBrandTableGateway($dbAdapter); $brandList = $brandsGateway->findAll(); if (isset($_GET["brandId"]) && $_GET["brandId"] != "") { $brandId = $_GET["brandId"]; $brand = $brandsGateway->findById($brandId); $brandResults = array($brand->name => $visitsGateway->countByDeviceBrand($brandId)); $brandHeaders = array("Brand", "Visits"); } /* * Retrieves all visit information for a specific continent */ $continentsGateway = new ContinentsTableGateway($dbAdapter); $continentList = $continentsGateway->findAll(); if (isset($_GET["continentCode"]) && $_GET["continentCode"] != "") { $continentCode = $_GET["continentCode"]; $countriesGateway = new CountriesTableGateway($dbAdapter); $countries = $countriesGateway->filterByContinentCode($continentCode); $countryResults = array(); foreach ($countries as $result) { $countryResults[$result->CountryName] = $visitsGateway->countByCountryCode($result->ISO);
$browser = $browserGate->findById($row['browser_id']); echo "<tr><td>" . $browser->name . "</td><td>" . $row['percentage'] . "%</td></tr>"; } echo "</tbody></table>"; ?> </div> <div class="mui-panel left bottom"> <!-- Dashboard Panel 2: Number of Visits by Device Brand --> <?php echo "<h3>Number of visits:<span id='showVisits'></span></h3>"; echo "<div class='mui-select' ><select id='brandList'><option value=''>Select a Brand:</option>"; foreach ($visitsByBrand as $row) { $brand = $brandGate->findById($row['device_brand_id']); echo "<option value='" . $row['count'] . "'>" . $brand->name . "</option>"; } echo "</select></div>"; ?> </div> </div> <div class="mui-col-md-6" > <div class="mui-panel" id="country-data"> <!-- Dashboard Panel 3: Number of Visits by Country --> <?php echo "<div class='mui-select' id='continentSelectWrapper'><select id='continentList'><option value=''>Select a Continent:</option>"; foreach ($continentResult as $row) {