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.

}<br />

?><br />

CHAPTER 4 ■ BUILD AN EVENTS CALENDAR<br />

■ Note That the Calendar class constructor accepts an optional $dbo argument that is passed in turn to the<br />

DB_Connect constructor. This allows you to create a database object <strong>and</strong> pass it for use in the class easily.<br />

Creating a File to Store Database Credentials<br />

To keep the database credentials separate from the rest of the application for easy maintenance, you<br />

want to use a configuration file. Create a new file called db-cred.inc.php in the config folder<br />

(/sys/config/db-cred.inc.php). Inside, create an array called $C (for constants), <strong>and</strong> store each piece of<br />

data as a new key-value pair:<br />

<br />

131

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

Saved successfully!

Ooh no, something went wrong!