Update of /cvsroot/phpweather/phpweather/db
In directory sc8-pr-cvs1:/tmp/cvs-serv24907/db
Modified Files:
pw_db_mysql.php pw_db_null.php
Log Message:
Added TAF support. Modified data_retrieval.php, defaults-dist.php, phpweather.php, pw_db_mysql.php, pw_db_null.php. Needs to add output functionality and support all backends.
Index: pw_db_mysql.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/db/pw_db_mysql.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- pw_db_mysql.php 28 Aug 2002 10:05:55 -0000 1.6
+++ pw_db_mysql.php 8 Sep 2003 04:20:44 -0000 1.7
@@ -223,6 +223,53 @@
return $this->fetch_row();
}
+ /**
+ * Inserts a TAF into the database.
+ *
+ * @param string The ICAO of the station.
+ * @param string The raw TAF.
+ * @param integer A standard UNIX timestamp.
+ * @access public
+ * @see update_taf()
+ */
+ function insert_taf($icao, $taf, $timestamp) {
+ $this->query(sprintf('INSERT INTO %s SET icao = "%s", ' .
+ 'taf = "%s", timestamp = FROM_UNIXTIME(%d)',
+ $this->properties['db_tafs'], $icao,
+ addslashes($taf), intval($timestamp)));
+ }
+
+ /**
+ * Updates an existing TAF in the database.
+ *
+ * @param string The ICAO of the station.
+ * @param string The raw TAF.
+ * @param integer A standard UNIX timestamp.
+ * @access public
+ * @see insert_taf()
+ */
+ function update_taf($icao, $taf, $timestamp) {
+ $this->query(sprintf('UPDATE %s' .
+ ' SET taf = "%s", timestamp = FROM_UNIXTIME(%d)' .
+ ' WHERE icao = "%s"',
+ $this->properties['db_tafs'], addslashes($taf),
+ intval($timestamp), $icao));
+ }
+
+ /**
+ * Gets a TAF form the database.
+ *
+ * @param string The ICAO of the station.
+ * @return string The raw TAF as an array from the database.
+ * @access public
+ */
+ function get_taf($icao) {
+ $this->query(sprintf('SELECT taf, UNIX_TIMESTAMP(timestamp)' .
+ ' FROM %s WHERE icao = "%s"',
+ $this->properties['db_tafs'], $icao));
+ return $this->fetch_row();
+ }
+
/**
* Creates the necessary tables in the database.
@@ -241,6 +288,15 @@
$this->query('CREATE TABLE ' . $this->properties['db_metars'] . '(
icao char(4) NOT NULL,
metar varchar(255) NOT NULL,
+ timestamp timestamp(14),
+ PRIMARY KEY (icao),
+ UNIQUE icao (icao))');
+
+ /* First we make a table for the TAFs */
+ $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_tafs']);
+ $this->query('CREATE TABLE ' . $this->properties['db_tafs'] . '(
+ icao char(4) NOT NULL,
+ taf varchar(255) NOT NULL,
timestamp timestamp(14),
PRIMARY KEY (icao),
UNIQUE icao (icao))');
Index: pw_db_null.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/db/pw_db_null.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- pw_db_null.php 28 Aug 2002 10:05:55 -0000 1.4
+++ pw_db_null.php 8 Sep 2003 04:20:44 -0000 1.5
@@ -98,6 +98,44 @@
}
/**
+ * Pretends to insert a TAF into the database.
+ *
+ * @param string The ICAO of the station.
+ * @param string The raw TAF.
+ * @param integer A standard UNIX timestamp.
+ * @access public
+ * @see update_taf()
+ */
+ function insert_taf($station, $taf, $timestamp) {
+ ;
+ }
+
+ /**
+ * Pretends to update an existing TAF in the database.
+ *
+ * @param string The ICAO of the station.
+ * @param string The raw TAF.
+ * @param integer A standard UNIX timestamp.
+ * @access public
+ * @see insert_taf()
+ */
+ function update_taf($station, $taf, $timestamp) {
+ ;
+ }
+
+ /**
+ * Pretends to return a TAF form the database.
+ *
+ * @param string The ICAO of the station.
+ * @return string Since we don't have a database, we just return an
+ * empty string.
+ * @access public
+ */
+ function get_taf($station) {
+ return '';
+ }
+
+ /**
* Fetches information about an ICAO.
*
* @param string The ICAO one want's to translate.
|