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

Class: TeraWurflDatabase_MongoDB

Source Location: /DatabaseConnectors/TeraWurflDatabase_MongoDB.php

Class Overview

TeraWurflDatabase
   |
   --TeraWurflDatabase_MongoDB

Provides connectivity from Tera-WURFL to MongoDB


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: TeraWurflDatabase

TeraWurflDatabase::__construct()
TeraWurflDatabase::clearTable()
Truncate or drop+create the given table
TeraWurflDatabase::connect()
Establishes a database connection and stores connection in $this->dbcon
TeraWurflDatabase::createCacheTable()
Creates the cache table
TeraWurflDatabase::createGenericDeviceTable()
Creates a table capable of holding devices (WURFL ID, User Agent and Capabilities)
TeraWurflDatabase::createIndexTable()
Creates the index table
TeraWurflDatabase::createProcedures()
Creates supporting stored procedures
TeraWurflDatabase::createSettingsTable()
Creates the settings table
TeraWurflDatabase::getActualDeviceAncestor()
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.
TeraWurflDatabase::getCachedUserAgents()
Returns and array of the cached User Agents
TeraWurflDatabase::getDeviceFallBackTree()
Find the matching Device ID for a given User Agent using LD (Leveshtein Distance)
TeraWurflDatabase::getDeviceFromCache()
Return capabilities array for the given User Agent, or null if not found
TeraWurflDatabase::getDeviceFromID()
Returns the capabilities array from a given WURFL Device ID
TeraWurflDatabase::getDeviceFromUA()
Returns the WURFL ID from a raw User Agent if an exact match is found
TeraWurflDatabase::getDeviceFromUA_LD()
Find the matching Device ID for a given User Agent using LD (Leveshtein Distance)
TeraWurflDatabase::getDeviceFromUA_RIS()
Find the matching Device ID for a given User Agent using RIS (Reduction in String)
TeraWurflDatabase::getFullDeviceList()
Returns an associative array of all the data from the given table in the form [WURFL ID] => [User Agent]
TeraWurflDatabase::getLastError()
Returns the most recent error message
TeraWurflDatabase::getMatcherTableList()
Returns an array of the User Agent Matcher tables in the database
TeraWurflDatabase::getServerVersion()
Returns the version string of the database server
TeraWurflDatabase::getSetting()
Get setting from settings table by a given key
TeraWurflDatabase::getTableList()
Returns an array of all the tables in the database
TeraWurflDatabase::getTableStats()
Returns an associative array of statistics from given table
TeraWurflDatabase::initializeDB()
Creates and prepares the database
TeraWurflDatabase::loadDevices()
Loads the pre-processed WURFL tables into the database
TeraWurflDatabase::rebuildCacheTable()
Rebuilds the cache table by redetecting the cached devices against the loaded WURFL
TeraWurflDatabase::saveDeviceInCache()
Save the given User Agent and Device capabilities array to the database
TeraWurflDatabase::SQLPrep()
Prepares raw text for use in queries (adding quotes and escaping characters if necessary)
TeraWurflDatabase::updateSetting()
Adds/updates a key=>value pair in the settings table
TeraWurflDatabase::verifyConfig()
Checks if the database configuration is correct and that all required permissions

Class Details

[line 21]
Provides connectivity from Tera-WURFL to MongoDB



Tags:



[ Top ]


Class Variables

static $CONNECTION_OPTIONS = array(
      "persist" => "Tera-WURFL",
//      "timeout" => 500,
//      "replicaSet" => true,
   )

[line 27]

MongoDB connection options



Tags:

link:  http://us.php.net/manual/en/mongo.construct.php
access:  protected

Type:   array


[ Top ]

static $MERGE =

[line 77]



Tags:

access:  protected

Type:   string


[ Top ]

static $PREALLOC_SIZE =  31457280

[line 87]



Tags:

access:  protected

Type:   int


[ Top ]

$connected =  false

[line 62]



Tags:

access:  public

Type:   boolean
Overrides:   Array


[ Top ]

$dbcon =

[line 72]



Tags:

access:  protected

Type:   MongoDB
Overrides:   Array


[ Top ]

$db_implements_fallback =  true

[line 46]



Tags:

access:  public

Type:   boolean
Overrides:   Array


[ Top ]

$db_implements_ld =  false

[line 52]



Tags:

todo:  See if this can be implemented
access:  public

Type:   boolean
Overrides:   Array


[ Top ]

$db_implements_ris =  true

[line 41]



Tags:

access:  public

Type:   boolean
Overrides:   Array


[ Top ]

$errors =

[line 36]



Tags:

access:  public

Type:   array
Overrides:   Array


[ Top ]

$mergecoll =

[line 82]



Tags:

access:  protected

Type:   MongoCollection


[ Top ]

$mongo =

[line 67]



Tags:

access:  protected

Type:   Mongo


[ Top ]

$numQueries =  0

[line 57]



Tags:

access:  public

Type:   int
Overrides:   Array


[ Top ]



Class Methods


constructor __construct [line 89]

TeraWurflDatabase_MongoDB __construct( )



Tags:

access:  public


Overrides TeraWurflDatabase::__construct() (parent method not documented)

[ Top ]

method clearTable [line 638]

void clearTable( $tablename)



Tags:

access:  public


Overrides TeraWurflDatabase::clearTable() (Truncate or drop+create the given table)

Parameters:

   $tablename  

[ Top ]

method collectionExists [line 506]

void collectionExists( $name)



Tags:

access:  public


Parameters:

   $name  

[ Top ]

method connect [line 444]

boolean connect( )

Establishes connection to database (does not check for DB sanity)



Tags:

access:  public


Overrides TeraWurflDatabase::connect() (Establishes a database connection and stores connection in $this->dbcon)

[ Top ]

method createCacheTable [line 270]

void createCacheTable( )

Drops, creates and indexes the cache table



Tags:

access:  public


Overrides TeraWurflDatabase::createCacheTable() (Creates the cache table)

[ Top ]

method createGenericDeviceTable [line 636]

void createGenericDeviceTable( $tablename)



Tags:

access:  public


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

Parameters:

   $tablename  

[ Top ]

method createIndexTable [line 639]

void createIndexTable( )



Tags:

access:  public


Overrides TeraWurflDatabase::createIndexTable() (Creates the index table)

[ Top ]

method createProcedures [line 385]

void createProcedures( )

Runs any stored procs needed to set up db



Tags:

access:  public


Overrides TeraWurflDatabase::createProcedures() (Creates supporting stored procedures)

[ Top ]

method createSettingsTable [line 256]

void createSettingsTable( )



Tags:

access:  public


Overrides TeraWurflDatabase::createSettingsTable() (Creates the settings table)

[ Top ]

method getActualDeviceAncestor [line 637]

void getActualDeviceAncestor( $wurflID)



Tags:

access:  public


Overrides TeraWurflDatabase::getActualDeviceAncestor() (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.)

Parameters:

   $wurflID  

[ Top ]

method getCachedUserAgents [line 536]

array getCachedUserAgents( )



Tags:

access:  public


Overrides TeraWurflDatabase::getCachedUserAgents() (Returns and array of the cached User Agents)

[ Top ]

method getDeviceFallBackTree [line 176]

void getDeviceFallBackTree( $wurflID)



Tags:

access:  public


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

Parameters:

   $wurflID  

[ Top ]

method getDeviceFromCache [line 282]

array getDeviceFromCache( string $userAgent)



Tags:

return:  Should return (bool) false or the device array
access:  public


Overrides TeraWurflDatabase::getDeviceFromCache() (Return capabilities array for the given User Agent, or null if not found)

Parameters:

string   $userAgent  

[ Top ]

method getDeviceFromID [line 102]

array getDeviceFromID( string $wurflID)



Tags:

return:  The device capabilities
throws:  Exception
access:  public


Overrides TeraWurflDatabase::getDeviceFromID() (Returns the capabilities array from a given WURFL Device ID)

Parameters:

string   $wurflID  

[ Top ]

method getDeviceFromUA [line 141]

void getDeviceFromUA( string $userAgent)

Exact match by user agent string



Tags:

access:  public


Overrides TeraWurflDatabase::getDeviceFromUA() (Returns the WURFL ID from a raw User Agent if an exact match is found)

Parameters:

string   $userAgent  

[ Top ]

method getDeviceFromUA_LD [line 630]

void getDeviceFromUA_LD( $userAgent, $tolerance, $matcher)



Tags:

access:  public


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

Parameters:

   $userAgent  
   $tolerance  
UserAgentMatcher   $matcher  

[ Top ]

method getDeviceFromUA_RIS [line 164]

string getDeviceFromUA_RIS( string $userAgent, int $tolerance, $matcher)

RIS == Reduction in String (reduce string one char at a time)



Tags:

return:  A TW Device ID
access:  public


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

Parameters:

string   $userAgent  
int   $tolerance  
UserAgentMatcher   $matcher  

[ Top ]

method getFullDeviceList [line 123]

array getFullDeviceList( string $tablename)



Tags:

access:  public


Overrides TeraWurflDatabase::getFullDeviceList() (Returns an associative array of all the data from the given table in the form [WURFL ID] => [User Agent])

Parameters:

string   $tablename  

[ Top ]

method getMatcherNameFromTable [line 187]

void getMatcherNameFromTable( $table)



Tags:

access:  protected


Parameters:

   $table  

[ Top ]

method getMatcherTableList [line 635]

void getMatcherTableList( )



Tags:

access:  public


Overrides TeraWurflDatabase::getMatcherTableList() (Returns an array of the User Agent Matcher tables in the database)

[ Top ]

method getServerVersion [line 376]

void getServerVersion( )



Tags:

access:  public


Overrides TeraWurflDatabase::getServerVersion() (Returns the version string of the database server)

[ Top ]

method getSetting [line 472]

void getSetting( $key)



Tags:

access:  public


Overrides TeraWurflDatabase::getSetting() (Get setting from settings table by a given key)

Parameters:

   $key  

[ Top ]

method getTableList [line 495]

array getTableList( )



Tags:

access:  public


Overrides TeraWurflDatabase::getTableList() (Returns an array of all the tables in the database)

[ Top ]

method getTableStats [line 515]

array getTableStats( string $table)



Tags:

access:  public


Overrides TeraWurflDatabase::getTableStats() (Returns an associative array of statistics from given table)

Parameters:

string   $table  

[ Top ]

method loadDevices [line 195]

void loadDevices( &$tables, array $tables)



Tags:

access:  public


Overrides TeraWurflDatabase::loadDevices() (Loads the pre-processed WURFL tables into the database)

Parameters:

array   $tables  
   &$tables  

[ Top ]

method rebuildCacheTable [line 332]

boolean rebuildCacheTable( )



Tags:

access:  public


Overrides TeraWurflDatabase::rebuildCacheTable() (Rebuilds the cache table by redetecting the cached devices against the loaded WURFL)

[ Top ]

method saveDeviceInCache [line 309]

boolean saveDeviceInCache( string $userAgent, array $device)



Tags:

return:  Whether the insert was successful
access:  public


Overrides TeraWurflDatabase::saveDeviceInCache() (Save the given User Agent and Device capabilities array to the database)

Parameters:

string   $userAgent  
array   $device  

[ Top ]

method SQLPrep [line 487]

mixed SQLPrep( mixed $value)

Prepare raw text for use in queries (adding quotes if necessary)



Tags:

access:  public


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

Parameters:

mixed   $value  

[ Top ]

method updateSetting [line 466]

void updateSetting( $key, $value)



Tags:

access:  public


Overrides TeraWurflDatabase::updateSetting() (Adds/updates a key=>value pair in the settings table)

Parameters:

   $key  
   $value  

[ Top ]

method _createCollection [line 596]

boolean _createCollection( string $collectionname)



Tags:

return:  Whether the operation was successful
access:  protected


Parameters:

string   $collectionname  

[ Top ]

method _dropCollectionIfExists [line 575]

boolean _dropCollectionIfExists( string $collectionname)



Tags:

return:  Whether the operation was successful
access:  protected


Parameters:

string   $collectionname  

[ Top ]

method _recreateCollection [line 558]

boolean _recreateCollection( string $collectionname)



Tags:

return:  Whether the operation was successful
access:  protected


Parameters:

string   $collectionname  

[ Top ]

method _renameCollection [line 614]

boolean _renameCollection( $from, $to)



Tags:

access:  protected


Parameters:

   $from  
   $to  

[ Top ]


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