Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: /www/gimpster.com/php/phpweather/db/db_null.php
PHP Weather - PHP Weather

db_null

base_object
   |
  +-- db_common
     |
    +-- db_null

This class is the 'null' database-type

 

private class db_null extends db_common

This class is the 'null' database-type
It pretends to be a database, but really it isn't :-) It just implements all the functions one would expect from a database, and then returns true or false or with empty strings and arrays as appropriate.

AuthorsMartin Geisler <gimpster@gimpster.com>
Versiondb_null.html,v 1.2 2001/06/27 11:35:43 gimpster Exp

 

Methods inherited from db_common

db_common

Methods inherited from base_object

base_object, error, debug, print_properties

Public Method Summary

void

db_null(array $input)

This constructor does nothing besides calling the parent constructor.
string

get_type()

Gets the type of the database.
boolean

connect()

Pretends to establish a connection to the database.
void

insert_metar(string $station, string $metar, integer $timestamp)

Pretends to insert a METAR into the database.
void

update_metar(string $station, string $metar, integer $timestamp)

Pretends to update an existing METAR in the database.
string

get_metar(string $station)

Pretends to return a METAR form the database.
string

lookup_icao(string $icao)

Translates an ICAO into a station name
array

get_countries()

Returns a list of available countries.
array

get_icaos(string $cc, string &$country)

Returns an array of stations.

Private Method Summary

bool

create_tables()

Makes sure that it's possible to create the files.
bool

insert_stations(array $data, array $countries)

Inserts the stations into the database.

Fields inherited from db_common

$is_connected, $link_id, $result_id

Fields inherited from base_object

$properties, $version

Public Method Details

db_null

public void db_null( array $input )

  This constructor does nothing besides calling the parent constructor.

Parameter
array $input
initial properties of the object
Returns void


get_type

public string get_type( )

  Gets the type of the database.

Returns string

The type of the database, 'null' in this case.


connect

public boolean connect( )

  Pretends to establish a connection to the database.
Like all the other methods of this database object, this doesn't do anything useful.

Returns boolean

Always returns true, so that other functions that depends on a connection to the database doesn't fail because of this.


insert_metar

public void insert_metar( string $station, string $metar, integer $timestamp )

  Pretends to insert a METAR into the database.

Parameter
string $station
ICAO of the station.
string $metar
raw METAR.
integer $timestamp
standard UNIX timestamp.
Returns void

See Also update_metar()

update_metar

public void update_metar( string $station, string $metar, integer $timestamp )

  Pretends to update an existing METAR in the database.

Parameter
string $station
ICAO of the station.
string $metar
raw METAR.
integer $timestamp
standard UNIX timestamp.
Returns void

See Also insert_metar()

get_metar

public string get_metar( string $station )

  Pretends to return a METAR form the database.

Parameter
string $station
ICAO of the station.
Returns string

Since we don't have a database, we just return an empty string.


lookup_icao

public string lookup_icao( string $icao )

  Translates an ICAO into a station name

Parameter
string $icao
ICAO to translate.
Returns string

The translated ICAO.


get_countries

public array get_countries( )

  Returns a list of available countries.
It uses the file PHPWEATHER_BASE_DIR/db/files/countries.php created by insert_stations().

Returns array

An associative array with the country-codes as the keys and the names of the countries as the values.


get_icaos

public array get_icaos( string $cc, string &$country )

  Returns an array of stations.

Parameter
string $cc
country-code.
string &$country
parameter is passed by reference. The name of the country that corresponds to the country-code is stored here.
Returns array

An associative array with the ICAO as the key and the name of the station as the values. The name of the country is not added to the name of the station.


Private Method Details

create_tables

private bool create_tables( )

  Makes sure that it's possible to create the files.
The method doesn't create any files, it just veryfies that it's we have write permission to PHPWEATHER_BASE_DIR/db.

Returns bool

True if it's possible to create files.


insert_stations

private bool insert_stations( array $data, array $countries )

  Inserts the stations into the database.
It is assumed that create_tables() has been called previously (and that it returned true), so that we can create the necessary files. insert_stations() populates PHPWEATHER_BASE_DIR/db/files/ with a file for each country. The files contain PHP code, so that $country and $icaos will be set, if the file is included.

Parameter
array $data
three-dimensional array starts with a list of contry-codes. For each country-code the ICAOs and corresponding locations in that particular country are listed as key => value pairs.
array $countries
associative array with country-codes as the keys and the names of the countries as the values.
Returns bool



Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta