LGV_TZ_Lookup 1.4.2
Time zone lookup for PHP applications and HTTP clients
Loading...
Searching...
No Matches
LGV_TZ_Lookup_Database Class Reference
Inheritance diagram for LGV_TZ_Lookup_Database:

Public Member Functions

 __construct ( $inDatabase, $inUser=NULL, $inPassword=NULL, $inDriver='mysql', $inHost='127.0.0.1', $inPort=NULL)
 get_tz_entities ( $in_id_list)
 get_tz_ids ( $in_lng, $in_lat)
 get_tz_polygons ($in_id_list)
 reset_database ()
 store_entity ( $inEntity)

Static Public Member Functions

static _array_flatten ( $inArray)

Public Attributes

 $pdo_instance

Protected Attributes

 $_load_table
 Destination for schema creation and polygon inserts; updater subclasses can stage a new load.

Static Private Member Functions

static _sort_by_domainSize ($in_A, $in_B)

Private Attributes

 $_init_sql

Detailed Description

This class manages interactions between the server and the database.

Definition at line 37 of file LGV_TZ_Lookup_Database.class.php.

Constructor & Destructor Documentation

◆ __construct()

LGV_TZ_Lookup_Database::__construct ( $inDatabase,
$inUser = NULL,
$inPassword = NULL,
$inDriver = 'mysql',
$inHost = '127.0.0.1',
$inPort = NULL )

The constructor.

Parameters
$inDatabasedatabase name (required)
$inUserdatabase user, optional
$inPassworddatabase password, optional
$inDriverdatabase server type (optional, default is 'mysql')
$inHostdatabase server host (optional, default is 127.0.0.1)
$inPortdatabase TCP port (optional, defaults to 3306 for mysql, 5432 for pgsql)

Definition at line 57 of file LGV_TZ_Lookup_Database.class.php.

References pdo_instance.

Member Function Documentation

◆ _array_flatten()

LGV_TZ_Lookup_Database::_array_flatten ( $inArray)
static

This is a simple "brute force" array flattener. It rounds the values to six significant digits, as well.

Parameters
$inArrayThe multi-dimensional array to be squished.

Definition at line 138 of file LGV_TZ_Lookup_Database.class.php.

Referenced by store_entity().

Here is the caller graph for this function:

◆ _sort_by_domainSize()

LGV_TZ_Lookup_Database::_sort_by_domainSize ( $in_A,
$in_B )
staticprivate

This is a sort callback that sorts, so the smaller domain gets put first.

Returns
: True, if $in_A < $inB
Parameters
$in_AThe first entity
$in_BThe second entity

Definition at line 113 of file LGV_TZ_Lookup_Database.class.php.

◆ get_tz_entities()

LGV_TZ_Lookup_Database::get_tz_entities ( $in_id_list)
Returns
: An array of simple arrays ([tzname, polygon]), which are the database entities of table rows that correspond to the IDs passed in.
Parameters
$in_id_listA list of IDs for the rows we want to check.

Definition at line 183 of file LGV_TZ_Lookup_Database.class.php.

References pdo_instance.

◆ get_tz_ids()

LGV_TZ_Lookup_Database::get_tz_ids ( $in_lng,
$in_lat )

This queries the database, and returns the TZ IDs.

Returns
: An array of integers, which are the database IDs of table rows that have the long/lat in their domainRects.
Parameters
$in_lngThe longitude
$in_latThe latitude

Definition at line 166 of file LGV_TZ_Lookup_Database.class.php.

References pdo_instance.

◆ get_tz_polygons()

LGV_TZ_Lookup_Database::get_tz_polygons ( $in_id_list)

Yield the existing binary polygons without unpacking them. Primary-key order makes first-match precedence explicit, matching the existing MySQL primary-key candidate scan.

Reimplemented in DemoTrackedDatabase, and TrackingDatabase.

Definition at line 220 of file LGV_TZ_Lookup_Database.class.php.

References pdo_instance.

◆ reset_database()

LGV_TZ_Lookup_Database::reset_database ( )

This replaces the loader's destination table and its indexes for the configured database driver.

Reimplemented in SQLiteDatabase.

Definition at line 233 of file LGV_TZ_Lookup_Database.class.php.

References pdo_instance.

◆ store_entity()

LGV_TZ_Lookup_Database::store_entity ( $inEntity)

This uses our PDO instance to save the entity as a table row.

Parameters
$inEntityThe entity to be saved into the database.

Definition at line 149 of file LGV_TZ_Lookup_Database.class.php.

References _array_flatten(), and pdo_instance.

Here is the call graph for this function:

Member Data Documentation

◆ $_init_sql

LGV_TZ_Lookup_Database::$_init_sql
private

The statements that initialize this connection's MySQL or PostgreSQL schema.

Definition at line 42 of file LGV_TZ_Lookup_Database.class.php.

◆ $_load_table

LGV_TZ_Lookup_Database::$_load_table
protected

Definition at line 45 of file LGV_TZ_Lookup_Database.class.php.

◆ $pdo_instance

LGV_TZ_Lookup_Database::$pdo_instance

This has our PDO connection to our database.

Definition at line 51 of file LGV_TZ_Lookup_Database.class.php.


The documentation for this class was generated from the following file: