TeraWurflDatabase
[ class tree: TeraWurflDatabase ] [ index: TeraWurflDatabase ] [ all elements ]

Class: TeraWurflDatabase

Source Location: /DatabaseConnectors/TeraWurflDatabase.php

Class Overview


Abstract class to provide a skeleton for the Tera-WURFL database connectors.


Author(s):

Variables

Methods


Child classes:

TeraWurflDatabase_MongoDB
Provides connectivity from Tera-WURFL to MongoDB
TeraWurflDatabase_MSSQL2005
Provides connectivity from Tera-WURFL to Microsoft SQL Server 2005/2008
TeraWurflDatabase_MySQL4
Provides connectivity from Tera-WURFL to MySQL 4. This connector is also compatible with MySQL 5.
TeraWurflDatabase_MySQL5
Provides connectivity from Tera-WURFL to MySQL 5

Class Details

[line 25]
Abstract class to provide a skeleton for the Tera-WURFL database connectors.



Tags:

abstract:  


[ Top ]


Class Variables

static $DB_TEMP_EXT =  "_TEMP"

[line 73]

Database table name extension for temporary tables



Tags:

access:  public

Type:   string


[ Top ]

$connected =  false

[line 63]

True if connection to database is active



Tags:

access:  public

Type:   bool


[ Top ]

$dbcon =

[line 68]

Raw database connection



Tags:

access:  protected

Type:   database_object


[ Top ]

$db_implements_fallback =  false

[line 48]

Database connector implements the building of a fallback tree directly



Tags:

access:  public

Type:   bool


[ Top ]

$db_implements_ld =  false

[line 43]

Database connector implements the LD search function directly



Tags:

access:  public

Type:   bool


[ Top ]

$db_implements_ris =  false

[line 38]

Database connector implements the RIS search function directly



Tags:

access:  public

Type:   bool


[ Top ]

$errors =

[line 33]

Errors



Tags:

access:  public

Type:   array


[ Top ]

$numQueries =  0

[line 53]

Number of queries to database



Tags:

access:  public

Type:   int


[ Top ]

$tablename =

[line 58]

Full table name to use for the search functions



Tags:

access:  public

Type:   string


[ Top ]



Class Methods


constructor __construct [line 76]


method clearTable [line 184]

bool clearTable( $tablename $tablename)

Truncate or drop+create the given table



Tags:

return:  Success
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::clearTable()
TeraWurflDatabase_MSSQL2005::clearTable()
TeraWurflDatabase_MySQL4::clearTable()
TeraWurflDatabase_MySQL5::clearTable()

Parameters:

$tablename   $tablename  

[ Top ]

method connect [line 189]

bool connect( )

Establishes a database connection and stores connection in $this->dbcon



Tags:

return:  Success
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::connect()
Establishes connection to database (does not check for DB sanity)
TeraWurflDatabase_MSSQL2005::connect()
Establishes connection to database (does not check for DB sanity)
TeraWurflDatabase_MySQL4::connect()
Establishes connection to database (does not check for DB sanity)
TeraWurflDatabase_MySQL5::connect()
Establishes connection to database (does not check for DB sanity)
TeraWurflDatabase_MySQL5_Profiling::connect()
Establishes connection to database (does not check for DB sanity)

[ Top ]

method createCacheTable [line 161]

bool createCacheTable( )

Creates the cache table



Tags:

return:  Success
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::createCacheTable()
Drops, creates and indexes the cache table
TeraWurflDatabase_MSSQL2005::createCacheTable()
TeraWurflDatabase_MySQL4::createCacheTable()
TeraWurflDatabase_MySQL5::createCacheTable()

[ Top ]

method createGenericDeviceTable [line 139]

bool createGenericDeviceTable( $tablename $tablename)

Creates a table capable of holding devices (WURFL ID, User Agent and Capabilities)



Tags:

return:  Success
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::createGenericDeviceTable()
TeraWurflDatabase_MSSQL2005::createGenericDeviceTable()
Drops and creates the given device table
TeraWurflDatabase_MySQL4::createGenericDeviceTable()
Drops and creates the given device table
TeraWurflDatabase_MySQL5::createGenericDeviceTable()
Drops and creates the given device table

Parameters:

$tablename   $tablename   Name of the table

[ Top ]

method createIndexTable [line 173]

bool createIndexTable( )

Creates the index table



Tags:

return:  success
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::createIndexTable()
TeraWurflDatabase_MSSQL2005::createIndexTable()
Drops and creates the index table
TeraWurflDatabase_MySQL4::createIndexTable()
Drops and creates the index table
TeraWurflDatabase_MySQL5::createIndexTable()
Drops and creates the index table

[ Top ]

method createProcedures [line 211]

bool createProcedures( )

Creates supporting stored procedures



Tags:

return:  Success
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::createProcedures()
Runs any stored procs needed to set up db
TeraWurflDatabase_MSSQL2005::createProcedures()
TeraWurflDatabase_MySQL5::createProcedures()

[ Top ]

method createSettingsTable [line 178]

bool createSettingsTable( )

Creates the settings table



Tags:

return:  success
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::createSettingsTable()
TeraWurflDatabase_MSSQL2005::createSettingsTable()
Creates the settings table if it does not already exist
TeraWurflDatabase_MySQL4::createSettingsTable()
Creates the settings table if it does not already exist
TeraWurflDatabase_MySQL5::createSettingsTable()
Creates the settings table if it does not already exist

[ Top ]

method getActualDeviceAncestor [line 93]

string getActualDeviceAncestor( $wurflID $wurflID)

Returns the WURFL ID for the Actual Device Root in the given device's fall back tree. This can be null if it does not exist.



Tags:

return:  WURFL ID
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getActualDeviceAncestor()
TeraWurflDatabase_MSSQL2005::getActualDeviceAncestor()
TeraWurflDatabase_MySQL4::getActualDeviceAncestor()
TeraWurflDatabase_MySQL5::getActualDeviceAncestor()

Parameters:

$wurflID   $wurflID   WURFL ID

[ Top ]

method getCachedUserAgents [line 238]

array getCachedUserAgents( )

Returns and array of the cached User Agents



Tags:

abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getCachedUserAgents()
TeraWurflDatabase_MSSQL2005::getCachedUserAgents()
TeraWurflDatabase_MySQL4::getCachedUserAgents()
TeraWurflDatabase_MySQL5::getCachedUserAgents()

[ Top ]

method getDeviceFallBackTree [line 127]

string getDeviceFallBackTree( string $wurflID)

Find the matching Device ID for a given User Agent using LD (Leveshtein Distance)



Tags:

return:  WURFL ID
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getDeviceFallBackTree()
TeraWurflDatabase_MySQL5::getDeviceFallBackTree()

Parameters:

string   $wurflID   WURFL ID

[ Top ]

method getDeviceFromCache [line 149]

array getDeviceFromCache( $userAgent $userAgent)

Return capabilities array for the given User Agent, or null if not found



Tags:

return:  Capabilities
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getDeviceFromCache()
TeraWurflDatabase_MSSQL2005::getDeviceFromCache()
TeraWurflDatabase_MySQL4::getDeviceFromCache()
TeraWurflDatabase_MySQL5::getDeviceFromCache()

Parameters:

$userAgent   $userAgent  

[ Top ]

method getDeviceFromID [line 87]

array getDeviceFromID( $wurflID $wurflID)

Returns the capabilities array from a given WURFL Device ID



Tags:

return:  Device capabilities
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getDeviceFromID()
TeraWurflDatabase_MSSQL2005::getDeviceFromID()
TeraWurflDatabase_MySQL4::getDeviceFromID()
TeraWurflDatabase_MySQL5::getDeviceFromID()

Parameters:

$wurflID   $wurflID   WURFL ID

[ Top ]

method getDeviceFromUA [line 105]

string getDeviceFromUA( $userAgent $userAgent)

Returns the WURFL ID from a raw User Agent if an exact match is found



Tags:

return:  WURFL ID
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getDeviceFromUA()
Exact match by user agent string
TeraWurflDatabase_MSSQL2005::getDeviceFromUA()
TeraWurflDatabase_MySQL4::getDeviceFromUA()
TeraWurflDatabase_MySQL5::getDeviceFromUA()

Parameters:

$userAgent   $userAgent  

[ Top ]

method getDeviceFromUA_LD [line 121]

string getDeviceFromUA_LD( $userAgent, int $tolerance, &$matcher, string $ua, UserAgentMatcher $matcher)

Find the matching Device ID for a given User Agent using LD (Leveshtein Distance)



Tags:

return:  WURFL ID
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getDeviceFromUA_LD()
TeraWurflDatabase_MSSQL2005::getDeviceFromUA_LD()
TeraWurflDatabase_MySQL5::getDeviceFromUA_LD()

Parameters:

string   $ua   User Agent
int   $tolerance   Tolerance that is still considered a match
UserAgentMatcher   $matcher   The UserAgentMatcherInstance that is matching the User Agent
   $userAgent  
UserAgentMatcher   &$matcher  

[ Top ]

method getDeviceFromUA_RIS [line 113]

string getDeviceFromUA_RIS( $userAgent, int $tolerance, &$matcher, string $ua, UserAgentMatcher $matcher)

Find the matching Device ID for a given User Agent using RIS (Reduction in String)



Tags:

return:  WURFL ID
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getDeviceFromUA_RIS()
RIS == Reduction in String (reduce string one char at a time)
TeraWurflDatabase_MSSQL2005::getDeviceFromUA_RIS()
TeraWurflDatabase_MySQL5::getDeviceFromUA_RIS()
TeraWurflDatabase_MySQL5_Profiling::getDeviceFromUA_RIS()

Parameters:

string   $ua   User Agent
int   $tolerance   How short the strings are allowed to get before a match is abandoned
UserAgentMatcher   $matcher   The UserAgentMatcherInstance that is matching the User Agent
   $userAgent  
UserAgentMatcher   &$matcher  

[ Top ]

method getFullDeviceList [line 99]

array getFullDeviceList( $tablename $tablename)

Returns an associative array of all the data from the given table in the form [WURFL ID] => [User Agent]



Tags:

abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getFullDeviceList()
TeraWurflDatabase_MSSQL2005::getFullDeviceList()
TeraWurflDatabase_MySQL4::getFullDeviceList()
TeraWurflDatabase_MySQL5::getFullDeviceList()

Parameters:

$tablename   $tablename  

[ Top ]

method getLastError [line 268]

string getLastError( )

Returns the most recent error message



Tags:

return:  Error message
access:  public


[ Top ]

method getMatcherTableList [line 227]

array getMatcherTableList( )

Returns an array of the User Agent Matcher tables in the database



Tags:

abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getMatcherTableList()
TeraWurflDatabase_MSSQL2005::getMatcherTableList()
TeraWurflDatabase_MySQL4::getMatcherTableList()
TeraWurflDatabase_MySQL5::getMatcherTableList()

[ Top ]

method getServerVersion [line 263]

string getServerVersion( )

Returns the version string of the database server



Tags:

abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getServerVersion()
TeraWurflDatabase_MySQL4::getServerVersion()
TeraWurflDatabase_MySQL5::getServerVersion()

[ Top ]

method getSetting [line 204]

string getSetting( string $key)

Get setting from settings table by a given key



Tags:

return:  value or NULL if not found
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getSetting()
TeraWurflDatabase_MSSQL2005::getSetting()
TeraWurflDatabase_MySQL4::getSetting()
TeraWurflDatabase_MySQL5::getSetting()

Parameters:

string   $key   setting name (key)

[ Top ]

method getTableList [line 222]

array getTableList( )

Returns an array of all the tables in the database



Tags:

abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getTableList()
TeraWurflDatabase_MSSQL2005::getTableList()
TeraWurflDatabase_MySQL4::getTableList()
TeraWurflDatabase_MySQL5::getTableList()

[ Top ]

method getTableStats [line 233]

array getTableStats( $table $table)

Returns an associative array of statistics from given table



Tags:

abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::getTableStats()
TeraWurflDatabase_MSSQL2005::getTableStats()
TeraWurflDatabase_MySQL4::getTableStats()
TeraWurflDatabase_MySQL5::getTableStats()

Parameters:

$table   $table  

[ Top ]

method initializeDB [line 243]

void initializeDB( )

Creates and prepares the database



Tags:

access:  public


[ Top ]

method loadDevices [line 133]

array loadDevices( string &$tables)

Loads the pre-processed WURFL tables into the database



Tags:

return:  Array of devices in fallback tree
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::loadDevices()
TeraWurflDatabase_MSSQL2005::loadDevices()
TeraWurflDatabase_MySQL4::loadDevices()
TeraWurflDatabase_MySQL5::loadDevices()

Parameters:

string   &$tables   Device tables

[ Top ]

method rebuildCacheTable [line 166]

bool rebuildCacheTable( )

Rebuilds the cache table by redetecting the cached devices against the loaded WURFL



Tags:

return:  Success
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::rebuildCacheTable()
TeraWurflDatabase_MSSQL2005::rebuildCacheTable()
TeraWurflDatabase_MySQL4::rebuildCacheTable()
TeraWurflDatabase_MySQL5::rebuildCacheTable()

[ Top ]

method saveDeviceInCache [line 156]

bool saveDeviceInCache( $userAgent $userAgent, $device $device)

Save the given User Agent and Device capabilities array to the database



Tags:

return:  Success
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::saveDeviceInCache()
TeraWurflDatabase_MSSQL2005::saveDeviceInCache()
TeraWurflDatabase_MySQL4::saveDeviceInCache()
TeraWurflDatabase_MySQL5::saveDeviceInCache()

Parameters:

$userAgent   $userAgent   User Agent
$device   $device   Device capabilities array

[ Top ]

method SQLPrep [line 217]

string SQLPrep( $raw_text $raw_text)

Prepares raw text for use in queries (adding quotes and escaping characters if necessary)



Tags:

return:  SQL-Safe text
abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::SQLPrep()
Prepare raw text for use in queries (adding quotes if necessary)
TeraWurflDatabase_MSSQL2005::SQLPrep()
TeraWurflDatabase_MySQL4::SQLPrep()
TeraWurflDatabase_MySQL5::SQLPrep()

Parameters:

$raw_text   $raw_text  

[ Top ]

method updateSetting [line 198]

void updateSetting( string $key, string $value)

Adds/updates a key=>value pair in the settings table



Tags:

abstract:  
access:  public


Overridden in child classes as:

TeraWurflDatabase_MongoDB::updateSetting()
TeraWurflDatabase_MSSQL2005::updateSetting()
TeraWurflDatabase_MySQL4::updateSetting()
TeraWurflDatabase_MySQL5::updateSetting()

Parameters:

string   $key   setting name (key)
string   $value   setting value

[ Top ]

method verifyConfig [line 256]

array verifyConfig( )

Checks if the database configuration is correct and that all required permissions

are properly configured




Tags:

return:  list of errors
access:  public


Overridden in child classes as:

TeraWurflDatabase_MySQL5::verifyConfig()

[ Top ]


Documentation generated on Sun, 19 Sep 2010 00:15:57 +0000 by phpDocumentor 1.4.3