Get all events from MySQL DB

This commit is contained in:
Karl August Høivik 2016-08-15 20:56:24 +02:00
parent 4ac73d0113
commit 9653716ff5
2 changed files with 16 additions and 2 deletions

View File

@ -1,11 +1,19 @@
<?php <?php
namespace pvv\side; namespace pvv\side;
use \mysqli;
require __DIR__.'/sql_config.php';
Class Events { Class Events {
public function getAllEvents(){ public function getAllEvents(){
global $url, $user,$pass,$db;
$events = array(); $events = array();
$ev = new OnceEvent("Test","Now","Never","sm0xe","Here"); $mysqli = new mysqli($url,$user,$pass,$db);
$events[0] = $ev; $result = $mysqli->query("SELECT name,start,stop,organiser,location FROM events");
while($row = $result->fetch_assoc()){
$ev = new OnceEvent($row['name'],$row['start'],$row['stop'],$row['organiser'],$row['location']);
array_push($events,$ev);
}
#array_sort($events);
return $events; return $events;
} }
} }

View File

@ -0,0 +1,6 @@
<?php
$url = "127.0.0.1";
$user = "user";
$pass = "password";
$db = "events";
?>