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.

C H A P T E R 4<br />

■ ■ ■<br />

Build an Events Calendar<br />

Now that you’re up to speed on the concept of object-oriented programming, you can start working on<br />

the project that will be the meat <strong>and</strong> potatoes of this book: the events calendar. It all starts here, <strong>and</strong> as<br />

this book progresses, you’ll be adding more <strong>and</strong> more functionality using both <strong>PHP</strong> <strong>and</strong> <strong>jQuery</strong>.<br />

Planning the Calendar<br />

Because you’re starting from absolute scratch, you need to take a minute to plan the application. This<br />

application will be database-driven (using MySQL), so the planning will take part in two stages: first the<br />

database structure <strong>and</strong> then a basic map of the application that will access <strong>and</strong> modify the database.<br />

Defining the Database Structure<br />

To make building the application much easier, the first thing you should plan is how the data will be<br />

stored. This shapes everything in the application.<br />

For a basic events calendar, all the information you’ll need to store is the following:<br />

• event_id: An automatically incremented integer that uniquely identifies each<br />

event<br />

• event_title: The title of the event<br />

• event_desc: A full description of the event<br />

• event_start: The start time of the event (in format YYYY-MM-DD HH:MM:SS)<br />

• event_end: The end time of the event (in format YYYY-MM-DD HH:MM:SS)<br />

Creating the Class Map<br />

The next step is to lay out the main class that will h<strong>and</strong>le all the actions our application will perform<br />

related to the calendar events. This class will be called Calendar; the methods <strong>and</strong> properties will be laid<br />

out like so:<br />

119

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

Saved successfully!

Ooh no, something went wrong!