Class Item Class for database based items

author Timo A. Hummel <Timo.Hummel@4fb.de>
version 0.1
copyright four for business 2003

 Methods

Constructor Function

Item(string $table, string $primaryKey, $lifetime) 

Parameters

$table

string

The table to use as information source

$primaryKey

string

The primary key to use

$lifetime

Filters the passed data using the functions defines in the _arrInFilters array.

_inFilter(mixed $data) : mixed
see \setFilters
access private

Parameters

$data

mixed

Data to filter

Returns

mixedFiltered data

_onLoad ()

_onLoad() : \none

Function which is called whenever an item is loaded. Inherited classes should override this function if desired.

Returns

\none

Filters the passed data using the functions defines in the _arrOutFilters array.

_outFilter(mixed $data) : mixed
see \setFilters
access private

Parameters

$data

mixed

Data to filter

Returns

mixedFiltered data

_setMetaObject()

_setMetaObject($objectname) 

Parameters

$objectname

deleteProperty ($type, $name) Deletes a custom property

deleteProperty(string $type, string $name) 

Parameters

$type

string

Specifies the type

$name

string

Specifies the name

get($field) Wrapper for getField (less to type)

get(string $field) : mixed

Parameters

$field

string

Specifies the field to retrieve

Returns

mixedValue of the field

getField($field) Gets the value of a specific field

getField(string $field) : mixed

Parameters

$field

string

Specifies the field to retrieve

Returns

mixedValue of the field

getMetaObject()

getMetaObject() 

getProperty ($type, $name) Sets a custom property

getProperty(string $type, string $name) : boolean

Parameters

$type

string

Specifies the type

$name

string

Specifies the name

Returns

booleanValue of the given property

loadBy ($field, $value) Loads an item by colum/field from the database

loadBy(string $field, string $value, bool $bSafe) : bool

Parameters

$field

string

Specifies the field

$value

string

Specifies the value

$bSafe

bool

use inFilter or not

Returns

boolTrue if the load was successful

loadByPrimaryKey ($value) Loads an item by ID from the database

loadByPrimaryKey(string $value) : bool

Parameters

$value

string

Specifies the primary key value

Returns

boolTrue if the load was successful

set($field, $value) Shortcut to setField

set(string $field, string $value, $safe) 

Parameters

$field

string

Specifies the field to set

$value

string

Specifies the value to set

$safe

setField($field, $value) Sets the value of a specific field

setField(string $field, string $value, boolean $safe) 

Parameters

$field

string

Specifies the field to set

$value

string

Specifies the value to set

$safe

boolean

Speficies if we should translate characters

Define the filter functions used when data is being stored or retrieved from the database.

setFilters(array $arrInFilters, array $arrOutFilters) : void

Examples:

$obj->setFilters(array('addslashes'), array('stripslashes')); $obj->setFilters(array('htmlencode', 'addslashes'), array('stripslashes', 'htmlencode'));

Parameters

$arrInFilters

array

inFilters array with function names

$arrOutFilters

array

outFilters array with function names

setProperty ($type, $name, $value) Sets a custom property

setProperty(string $type, string $name, string $value) 

Parameters

$type

string

Specifies the type

$name

string

Specifies the name

$value

string

Specifies the value

store() Stores the modified user object to the database

store() 

 Properties

 

$_arrInFilters : array
access private
 

$_arrOutFilters : array
access private
 

$_metaObject 
 

$cache : array
access private
 

$db : object
access private
 

$lasterror : string
access private
 

Lifetime in seconds

$lifetime : int
access private
 

$modifiedValues : array
access private
 

$oldPrimaryKey : string
access private
 

$primaryKey : object
access private
 

PropertyCollection object

$properties : object
access private
 

$table : string
access private
 

$values : array
access private
 

$virgin : boolean

If true, the object is virgin and no operations on it except load-Functions are allowed.

access private