02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

140<br />

CHAPTER 4 ■ BUILD AN EVENTS CALENDAR<br />

)<br />

)<br />

(<br />

)<br />

[id] => 1<br />

[title] => New Year's Day<br />

[description] => Happy New Year!<br />

[start] => 2010-01-01 00:00:00<br />

[end] => 2010-01-01 23:59:59<br />

[31] => Array<br />

(<br />

[0] => Event Object<br />

(<br />

[id] => 2<br />

[title] => Last Day of January<br />

[description] => Last day of the month! Yay!<br />

[start] => 2010-01-31 00:00:00<br />

[end] => 2010-01-31 23:59:59<br />

)<br />

)<br />

Creating an Event Class<br />

To accomplish this, you must first create a new class called Event in the class folder<br />

(/sys/class/class.event.inc.php). It will have five public properties: $id, $title, $description, $start,<br />

<strong>and</strong> $end; <strong>and</strong> a constructor that will set each of those properties using the associative array returned <strong>by</strong><br />

the database query. Create the file, <strong>and</strong> insert the following code inside it:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!