I'm setting up the calendar and I am having trouble switching from the sqlite database in the tutorial to my mysql database.
I'm using the tutorial code created and populated a mysql databse using _db.php with the PDO connecting to my localhost mysql database (the database and data created fine).
The trouble is that DayPilot isn't loading the events when they are passed from mysql, I simplified the backend_events.php code to the following
<?php
//$db = new PDO("mysql:host=localhost;dbname=test", "root", "password"); // DOESN'T WORK WHEN I USE THIS ONE
$db = new PDO('sqlite:daypilot.sqlite'); //WORKS WHEN I USE THIS ONE
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare('SELECT * FROM events');
$stmt->execute();
$result = $stmt->fetchAll();
class Event {}
$events = array();
foreach($result as $row) {
$e = new Event();
$e->id = $row['id'];
$e->text = $row['name'];
$e->start = $row['start'];
$e->end = $row['end'];
$events[] = $e;
}
header('Content-Type: application/json');
echo json_encode($events);
?>
I'm confused because the return value is identical no matter which database I connect to.
[{"id":"1","text":"Event 1","start":"2014-10-10T00:00:00","end":"2014-10-10T10:00:00"}]
but for some reason I can't fathom DayPilot isn't loading the events. (my index.php is the unchanged tutorial file)