\Luxor_Driver_sql

Luxor storage implementation for PHP's PEAR database abstraction layer.

The table structure can be created by the scripts/drivers/luxor.sql script.

$Horde: luxor/lib/Driver/sql.php,v 1.29 2007/09/23 13:32:35 jan Exp $

Summary

Methods
Properties
Constants
factory()
Luxor_Driver_sql()
index()
reference()
fileId()
createFileId()
symid()
symname()
isSymbol()
toIndex()
toReference()
getLastModified()
clearCache()
clearIndex()
getDecId()
getIndex()
getReference()
searchSymbols()
getSourceBySymbol()
_connect()
$_params
$_db
$_source
$_connected
$_symcache
$_decIdcache
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$_params

$_params : array

Hash containing connection parameters.

Type

array

$_db

$_db : \DB

Handle for the current database connection.

Type

\DB

$_source

$_source : string

The id of the source that we are dealing with.

Type

string

$_connected

$_connected : boolean

Boolean indicating whether or not we're connected to the SQL server.

Type

boolean

$_symcache

$_symcache : array

Symbol cache.

Type

array

$_decIdcache

$_decIdcache : array

Description ID cache.

Type

array

Methods

factory()

factory(  $source, string  $driver = null, array  $params = null) : mixed

Attempts to return a concrete Luxor_Driver instance based on $driver.

Parameters

$source
string $driver

The type of concrete Luxor_Driver subclass to return. The is based on the storage driver ($driver). The code is dynamically included.

array $params

(optional) A hash containing any additional configuration or connection parameters a subclass might need.

Returns

mixed —

The newly created concrete Luxor_Driver instance, or false on an error.

Luxor_Driver_sql()

Luxor_Driver_sql(string  $source, array  $params = array()) 

Constructs a new SQL storage object.

Parameters

string $source

The name of the source.

array $params

A hash containing connection parameters.

index()

index(string  $symname, integer  $fileId, integer  $line, integer  $langid, integer  $type) : mixed

Adds a symbol definition to the sybmol index.

Parameters

string $symname

The symbol's name.

integer $fileId

The unique ID of the file where this symbol was defined.

integer $line

The linenumber where this symbol was defined.

integer $langid

The unique ID of the language the file was written in.

integer $type

The symbol type.

Returns

mixed —

PEAR_Error on error, true on success.

reference()

reference(string  $symname, integer  $fileId, integer  $line) : mixed

Add a symbol reference to the reference index.

Parameters

string $symname

The name of the used symbol.

integer $fileId

The unique ID of the file in which the symbol was used.

integer $line

The number of line in which the symbol was used.

Returns

mixed —

PEAR_Error on error, true on success.

fileId()

fileId(string  $filename, string  $tag = '') : integer

Returns a unique ID for a given filename.

Parameters

string $filename

The name of the file.

string $tag

The tag of the file.

Returns

integer —

A unique ID for this file or PEAR_Error on error.

createFileId()

createFileId(string  $filename, string  $tag = '', integer  $lastmodified = false) : integer

Created a unique ID for a given filename.

Parameters

string $filename

The name of the file.

string $tag

The tag of the file.

integer $lastmodified

The timestamp the file was last modified.

Returns

integer —

A unique ID for this file or PEAR_Error on error.

symid()

symid(string  $symname) : integer

Returns a unique ID for a given symbol.

Parameters

string $symname

The name of the symbol.

Returns

integer —

A unique ID for this symbol or PEAR_Error on error.

symname()

symname(integer  $symid) : string

Returns the name of a symbol from its unique ID.

Parameters

integer $symid

The ID of the symbol

Returns

string —

The name of the symbol or PEAR_Error on error

isSymbol()

isSymbol(string  $symname,   $altsources = array()) : integer

Checks if the given name is a known symbol.

Parameters

string $symname

The potential symbol name.

$altsources

Returns

integer —

The symbol's id or null if it wasn't a symbol.

toIndex()

toIndex(integer  $fileId) : boolean

If this file has not been indexed earlier, mark it as being indexed now.

Parameters

integer $fileId

The file's unique ID.

Returns

boolean —

True if the file has been marked as being indexed, false if it was already indexed.

toReference()

toReference(integer  $fileId) : boolean

If this file has not been referenced earlier, mark it as being referenced now.

Parameters

integer $fileId

The file's unique ID.

Returns

boolean —

True if the file has been marked as being referenced, false if it was already referenced.

getLastModified()

getLastModified(string  $filename) : integer

Return the last time the entry for a file was modified.

Parameters

string $filename

The filename to check.

Returns

integer —

The last modified time, or 0 if there is an error.

clearCache()

clearCache() 

Empties the current symbol cache.

This function should be called before parsing each new file. If this is not done too much memory will be used and things will become very slow.

clearIndex()

clearIndex() 

Cleans the database for a fresh import of data.

This function should be called before parsing the source tree again, to avoid duplicate entries in the database.

getDecId()

getDecId(integer  $lang, string  $string) 

Returns an unique ID for a description of a symbol type.

Parameters

integer $lang

The language's unique ID.

string $string

The symbol type description.

return mixed A unique ID for this description or PEAR_Error on error.

getIndex()

getIndex(integer  $symid, string  $tag = '') : array

Locate the definitions of a symbol.

Parameters

integer $symid

The symbol id.

string $tag

The tag of the file.

Returns

array —

Nested hash with elements 'filename', 'line', and 'declaration'.

getReference()

getReference(integer  $symid, string  $tag = '') : array

Locate the usage of a symbol.

Parameters

integer $symid

The symbol id.

string $tag

The tag of the file.

Returns

array —

Nested hash with elements 'filename', and 'line'.

searchSymbols()

searchSymbols(string  $symbol) : array

Search for symbols matching $symbol.

Parameters

string $symbol

The symbol name to search for.

Returns

array —

Any symids matching $symbol.

getSourceBySymbol()

getSourceBySymbol(  $symid) : string

Get source that a symbol is from.

Parameters

$symid

The symbol id.

Returns

string —

The source id.

_connect()

_connect() : boolean

Attempts to open a persistent connection to the SQL server.

Returns

boolean —

True on success.