Reusing the uars_day Class
Reusing the uars_day Class
A HRDIODB uars_day class instance can read and write information
related to a single UARS day. This tutorial will show you how to use the
HRDIODB uars_day class in your project to interact with the HRDI
database.
Written by Ziba R. Scott
and Adam D. Gorski
Table of Contents
Required classes
The uars_day class depends upon the hrdi_db class which
requires and is a child class of the mcpear class. Your project
must have access to each of these three classes by including the following
files:
Optionally, you may be interested in including the debugging debugging.php
file for convenience functions.
Create the class instances
The uars_day class is related to the hrdi_db class by
composition and requires it as an argument to the constructor. The hrdi_db
class requires a DSN as an argument to its constructor. A DSN is
the "Data Source Name" which is of the format:
phptype(dbsyntax)://username:password@protocol+hostspec/database
or more simply: phptype://username:password@hostspec.
You can either write your own DSN variable, copy the variable from conf.php
or include conf.php. Including conf.php will put
all the variables from conf.php into your global name space. The
uars_day class constructor also requires an integer representing
the UARS Day that the instance will represent.
/* HRDI configuration file */
require_once("conf.php");
/* HRDI specific database interface */
require_once("hrdi_db_class.php");
/* HRDI specific search methods */
require_once("uars_day_class.php");
$MyUarsDay = 71;
Reading UARS Day Information
Once the class instance has been made (with a valid UARS Day), it is
populated with data automatically. See the uars_day class
documentation for a complete list of the contents of the instance.
// Example usage of a $day object instance
Editing UARS Day Information
Once a day instance has been created the values in the associative array
$day->data can be edited and saved to the database.
Only existing values will be saved. Day creation is the responsibility of
the CSV interface.
$new_data = $day->data;
$new_data["Beta_Angle"] = 40;
$day->save($new_data)