Dan,
I was wondering if you have an example of the event retrieval working against MySQL?
My adapted code adds events to MySQL but it never shows the events?
Checking the apache logs i saw an error:
Uncaught Error: Cannot use object of type stdClass as array in ....
So I changed the code from $row{'id'] to $row->id now I get no errors but still no events showing?
My code is following maybe you could spot my mistake?
Thanks
Martin
<?php
session_start();
error_reporting(0);
include('includes/config.php');
//$sql = "SELECT id,EventName,EventStartDate,EventEndDate FROM tblcalendarevents WHERE NOT ((EventEndDate <= :start) OR (EventStartDate >= :end))";
$sql = "SELECT * FROM tblcalendarevents";
$query = $dbh->prepare($sql);
//$query->bindParam(':start',$_GET['start'],PDO::PARAM_STR);
//$query->bindParam(':end',$_GET['end'],PDO::PARAM_STR);
$query->execute();
$results = $query->fetchAll();
//$results=$query->fetchAll(PDO::FETCH_OBJ);
echo $query->rowCount();
class Event {}
$events = array();
if($query->rowCount() > 0)
{
foreach($results as $row)
{
// echo $row['id'];
$e = new Event();
$e->id = $row['id'];
$e->text = $row['EventName'];
$e->start = $row['EventStartDate'];
$e->end = $row['EventEndDate'];
// $e->id = $row->id;
// $e->text = $row->EventName;
// $e->start = $row->EventStartDate;
// $e->end = $row->EventEndDate;
$events[] = $e;
}
print_r ($events);
}
else
{
echo "No data found";
}
header('Content-Type: application/json');
echo json_encode($events);