Class: DatabaseFacet
A package for generating multi-faceted browsing interfaces for web sites. A facet
will look something like this:
Browse by Section
-----------------
Local(16), Sports(24),
World(21)
Usage Example
<?php
loader_import ('saf.Database.Facet');
$facet = new DatabaseFacet (db_table ('products', 'id'), 'category', 'Category');
$facet->compile ();
echo $facet->show ();
?>
Return to Top
Properties
$connection
Contains the database connection resource.
$path
Path to the Berkeley Database.
$mode
Mode to use when opening the database (corresponds to
the modes available to the dba_open () function.
$handler
The database implementation used (db2, db3, gdbm, etc.).
$persistent
A 1 or 0 (true or false, and true by default), specifying whether
to establish a persistent connection or not.
$transactions = 0
Boolean value denoting whether to enable transactions in the
current database.
$driver
Contains the name of the database driver being used.
$host
Contains the name of the database host.
$name
Contains the name of the database being used.
$user
Contains the username used to connect to the current database.
$pass
Contains the password used to connect to the current database.
$dbd
Contains the loaded database driver.
$error = false
Contains connection error information.
$sql = ''
Contains the SQL query to be executed.
$rows
Contains the number of rows returned by the previous fetch() call.
$lastid
Contains the lastid() of the last insert query sent to the execute()
method.
$tables = false
Contains a list of tables in the database. Set by getTables().
$pearEmu = false
$sequenceFormat = '%s_seq'
$fetchMode = DB_FETCHMODE_OBJECT
$result = ''
Contains the result identifier for the current execution.
$field = ''
Currently unused.
$_fetchModeFunctions = array (
DB_FETCHMODE_ASSOC => 'mysql_fetch_array',
DB_FETCHMODE_OBJECT => 'mysql_fetch_object',
)
$typemap = array (
'bpchar' => 'text',
'char' => 'text',
'varchar' => 'text',
'text' => 'textarea',
'date' => 'date',
'time' => 'time',
'timestamp' => 'datetime',
'.*' => 'text',
// arrays
// booleans
// blobs
)
Contains a key/value list of database types (regular
expressions are used here to save repeating ourselves) and their
corresponding MailForm widget types.
$column
Column name of the facet.
$title
Dispaly name of the facet.
$extra
Extra info about the facet.
$tableObj
DatabaseTable object.
$items = array ()
List of options in the facet.
$type = 'normal'
Type of the facet. Possible values are 'normal', 'self_ref', 'date', and 'time'.
This value is auto-determined by compile(), but can be customized as well.
Return to Top
Methods
DatabaseFacet (&$tableObj, $column, $title, $extra = '')
Constructor method.
compile ()
Compile the facet options from the database.
addItem ($id, $title, $count = 0)
Add an item to the list. Used internally by compile().
show ($linkUrl = '?')
- Access: public
- Return: string
Render the facet to HTML.
Return to Top