Overview   Package   Tree   Index 
Tv2 documentation
PREV  NEXT FRAMES  NO FRAME 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

tv2-engine
Class ctlIndexer


class ctlIndexer

General purpose indexer.

Authors:
Emilis Dambauskas (emilis@gildija.lt)
Version:
$Id: ctlIndexer.class.php,v 1.3 2003/09/16 03:00:28 lunaticlt Exp $
Copyright:
2002–2003 Emilis Dambauskas under Artistic license

Field Summary
private object$db
Database
private string$fkeys
Float keys table name
private string$ikeys
Int keys table name
private array$indices
Indexes array
private string$itable
Indices table name
private string$skeys
String keys table name
private string$slists
String value lists table

Constructor Summary
void ctlIndexer()
Constructor.

Method Summary
boolean addItem(integer $id, string $iname, mixed $val)
Adds item to index
boolean createIndex(string $iname, [string $type])
Creates a new index
boolean dropIndex(string $iname)
Removes index
boolean emptyIndex(string $iname)
Removes values from index
mixed getByIndex(string $iname)
Returns array of item ids indexed by values
mixed getByPreg(string $iname, string $preg)
Returns an array of item ids matching a regular expression.
mixed getByRange(string $iname, [mixed $from], [boolean $fs], [mixed $to], [boolean $ts])
Returns items whose values are in a range.
mixed getByValue(string $iname, mixed $val)
Returns an array of item ids that have common value
mixed getByValueList(string $iname, array $vals)
Returns an array of item ids which have values specified in $vals
mixed getValues(string $iname)
Returns an array of values stored in index
boolean load(array $tables)
Loads indices from table, assignes values to table name attributes
void removeItem(integer $id)
Removes item from index tables
mixed sortIdList(array $ids, string $iname, [string $direction])
Sorts item id list by indexed value
boolean updateItem(integer $id, string $iname, mixed $val)
Updates indexed item value


Field Detail

db

private object $db

Database


fkeys

private string $fkeys

Float keys table name


ikeys

private string $ikeys

Int keys table name


indices

private array $indices

Indexes array


itable

private string $itable

Indices table name


skeys

private string $skeys

String keys table name


slists

private string $slists

String value lists table


Constructor Detail

ctlIndexer()

void ctlIndexer()

Constructor. Links $this->db to db, creates empty $this->indices array

Uses the global variables:
db

Method Detail

addItem()

boolean addItem(integer $id, string $iname, mixed $val)

Adds item to index

Parameters:
id - item id
iname - index name
val - item value
Returns:
TRUE on success, FALSE on failure

createIndex()

boolean createIndex(string $iname, [string $type])

Creates a new index

Parameters:
iname - Index name
type - Index type (one of: string, int, float). Default: string
Returns:
TRUE on success, FALSE on failure

dropIndex()

boolean dropIndex(string $iname)

Removes index

Parameters:
iname - Index name
Returns:
TRUE on success, FALSE on failure

emptyIndex()

boolean emptyIndex(string $iname)

Removes values from index

Parameters:
iname - Index name
Returns:
TRUE on success, FALSE on failure

getByIndex()

mixed getByIndex(string $iname)

Returns array of item ids indexed by values

Parameters:
iname - Index name
Returns:
array of item indexes or NULL if no values/no index found

getByPreg()

mixed getByPreg(string $iname, string $preg)

Returns an array of item ids matching a regular expression.

Parameters:
iname - index name
preg - regular expression. Full Perl-compatible regexp should be specified (e.g. /foo/i).
Returns:
array on success, NULL on no results, FALSE on error

getByRange()

mixed getByRange(string $iname, [mixed $from], [boolean $fs], [mixed $to], [boolean $ts])

Returns items whose values are in a range. Applies only to int and float indexes.

Parameters:
iname - index name
from - lower value. NULL if not specified. Note that 0 (zero) is a value.
fs - "from strict"? if TRUE '>' will be used, otherwise '>='. Defaults to FALSE.
to - upper value. NULL if not specified. Note that 0 (zero) is a value.
ts - "to strict"? if TRUE '<' will be used, '<=' otherwise. Defaults to FALSE.
Returns:
array of item ids or FALSE on failure

getByValue()

mixed getByValue(string $iname, mixed $val)

Returns an array of item ids that have common value

Parameters:
iname - index name
val - item value
Returns:
array of item ids or FALSE on failure

getByValueList()

mixed getByValueList(string $iname, array $vals)

Returns an array of item ids which have values specified in $vals

Parameters:
iname - index name
vals - array of item values
Returns:
array of item ids or FALSE on failure

getValues()

mixed getValues(string $iname)

Returns an array of values stored in index

Parameters:
iname - Index name
Returns:
array of values on success, FALSE on failure

load()

boolean load(array $tables)

Loads indices from table, assignes values to table name attributes

Parameters:
tables - array of table names. Format: array('itable'=>'index_table', 'ikeys'=>'int_keys'...)
Returns:
TRUE on success, FALSE on failure

removeItem()

void removeItem(integer $id)

Removes item from index tables

Parameters:
id - item id

sortIdList()

mixed sortIdList(array $ids, string $iname, [string $direction])

Sorts item id list by indexed value

Parameters:
ids - item id array
iname - index name
direction - order direction (ASC/DESC)
Returns:
sorted id list, FALSE on failure

updateItem()

boolean updateItem(integer $id, string $iname, mixed $val)

Updates indexed item value

Parameters:
id - item id
iname - index name
val - item value
Returns:
TRUE on success, FALSE on failure

 Overview   Package   Tree   Index 
Tv2 documentation
PREV  NEXT FRAMES  NO FRAME 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Submit a bug

This document was generated by phpdocgen 0.17-rc3.
Copyright © 2002-03 Stéphane GALLAND (under the GNU General Public License)