phpPeanuts  2.2.0
phpPeanuts framework
 All Data Structures Namespaces Files Functions Variables
Public Member Functions | Data Fields
PntDbClassDescriptor Class Reference

Inherits PntClassDescriptor.

Public Member Functions

 __construct ($name)
 
 addPropertyDescriptor ($aPntPropertyDescriptor)
 
 setPolymorphismPropName ($value)
 
 getPersistentFieldPropertyDescriptors ()
 
 getPersistentValuePropertyDescriptors ()
 
 getPersistentRelationPropertyDescriptors ($type='PntDbObject')
 
 getTableName ()
 
 initTableMap (&$anArray)
 
 getTableMap ()
 
 getFieldMap ()
 
 getFieldMapPrefixed ()
 
 getFieldMapForTable ($tableName)
 
 getSelectQueryHandler ()
 
 getSelectQueryHandlerFor ($tableName, $tableMap, $fieldMapPrefixed)
 
 getSimpleQueryHandler ()
 
 getFilters ($depth)
 
 getAllFieldsFilter (&$filters, $type)
 
 getFieldFilters ()
 
 getDefaultFilters ($depth)
 
 addReferenceFilters (&$result, $prop, $depth)
 
 getLabelSort ($filter=null)
 
 getVerifyOnDelete ()
 
 getDescribedClassInstanceForData ($assocArray, $delegator)
 
 checkPolyClassName ($className)
 
 setPolyClassesAllowed ($map)
 
 loadMissingFields ($peanut, $id, &$missingFieldsMap, $delegator)
 
 peanutDeleted ($id)
 
 peanutInserted ($peanut)
 
 peanutCached ($id)
 
 getPeanutsRunQueryHandler ($qh, $sortPath=null)
 
 getPeanuts ()
 
 getPeanutsWith ($propertyName, $value)
 
 getPeanutWithId ($id)
 
 getPeanutsAccordingTo ($spec)
 
 getPeanutsCount ($filter)
 
 _loadMissingFields ($peanut, $id, &$missingFieldsMap, $delegator)
 
 _getPeanutsRunQueryHandler ($qh, $sortPath=null)
 
 _getDescribedClassInstanceForData ($assocArray, $delegator)
 
- Public Member Functions inherited from PntClassDescriptor
 __construct ($name=null)
 
 isPropertyDescriptorSet ($propertyName)
 
 getPropertyDescriptors ()
 
refPropertyDescriptors ()
 
 getMultiValuePropertyDescriptors ()
 
 getSingleValuePropertyDescriptors ()
 
 getPropertyDescriptor ($name)
 
 getTwinOf_type ($propName, $type)
 
 addPropertyDescriptor ($anPntPropertyDescriptor)
 
 hasPropertyDescriptor ($name)
 
 getClassDir ()
 
 getLabel ()
 
 getUiColumnPaths ()
 
 getUiFieldPaths ()
 
 getUiPropertyDescriptors ()
 
 getParentclassDescriptor ()
 
 getDefaultLabelProp ($candidates, $reject)
 
 getVerifyOnDelete ()
 
 getPeanutWithId ($id)
 
 getPeanuts ()
 
 getPeanutsWith ($propertyName, $value)
 
 getPeanutsAccordingTo ($spec)
 
 _getPeanuts ()
 
 _getPeanutsWith ($propertyName, $value)
 
 _getPeanutWithId ($id)
 
- Public Member Functions inherited from PntDescriptor
 getName ()
 
 setName ($aString)
 
 getLabel ()
 
 setLabel ($aString)
 
 __toString ()
 
 toString ()
 

Data Fields

 $polymorphismPropName = null
 
 $tableName
 
 $fieldMap
 
 $peanutsById
 
 $polyClassesAllowed
 
- Data Fields inherited from PntClassDescriptor
 $propertyDescriptors
 
 $name
 
- Data Fields inherited from PntDescriptor
 $name
 
 $label
 

Additional Inherited Members

- Static Public Member Functions inherited from PntClassDescriptor
static & getInstances ()
 
static getInstance ($name)
 

Constructor & Destructor Documentation

__construct (   $name)

Member Function Documentation

_getDescribedClassInstanceForData (   $assocArray,
  $delegator 
)
_getPeanutsRunQueryHandler (   $qh,
  $sortPath = null 
)
_loadMissingFields (   $peanut,
  $id,
$missingFieldsMap,
  $delegator 
)
addPropertyDescriptor (   $aPntPropertyDescriptor)
addReferenceFilters ( $result,
  $prop,
  $depth 
)
checkPolyClassName (   $className)

Check wheather the class name is allowed for polymorphic persistency

Parameters
string$classNamethe class name
getAllFieldsFilter ( $filters,
  $type 
)
getDefaultFilters (   $depth)
Returns
Array of PntSqlFilter filters derived from metadata
getDescribedClassInstanceForData (   $assocArray,
  $delegator 
)

Returns an instance of the described class or if polymorphismPropName is set, from class according to data initialized from the data in the supplied associative array. When loading several tables may have been JOINed by the database. Eventually missing data is loaded using an extra query. In case of polymorphic retrieval that starts with a supertype, the mechanism is not efficient for the habit of MySQL not to include keys for null values: it causes en extra query to load 'missing' fields that are already queried for. It would be better to fetch the data as an indexed array, than map the indexes directly to fields...

Returns
PntDbObject (new or from chache)
Exceptions
PntError
getFieldFilters ( )
Returns
Array of PntSqlFilter filters derived from metadata
getFieldMap ( )

Returns the field to column mapping for the described class. For polymorphic persistency a single peanut can be mapped to several tables. This funtion returns a single fieldmap for all tables. When loading several tables may be JOINed by the database. Eventually missing data is loaded using an extra query.

See Also
_getDescribedClassInstanceForData

Because a fields persistence can be PNT_READ_ONLY, the map for loading the object is not necessarily the same as the map for saving. This method returns the fieldmap for loading, this includes fields whose propertyDescriptors' persistent === PNT_READ_ONLY

! There may still be methods that are not supporting fieldmapping ! Returns reference to cached Array, allways reset before using forEach or while each

Returns
columnNameMapping Associative Array with field names as the keys and (unprefixed) column names as the values
getFieldMapForTable (   $tableName)

For polymorphic persistency a single peanut can be mapped to several tables. This funtion returns a specific fiedMap for each table Because a fields persistence can be PNT_READ_ONLY, the map for loading the object is not necessarily the same as the map for saving. This method returns the fieldmap for saving, this excludes fields whose propertyDescriptors' persistent === PNT_READ_ONLY

Parameters
String$tableNamethe name of the table to get the map for
Returns
array fieldmap for saving, with fieldNames as keys and columnNames as values
getFieldMapPrefixed ( )

Returns the field to column mapping for the described class.

! There may still be methods that do not yet support column mapping ! Returns reference to cached Array, allways reset before using forEach or while each

Returns
columnNameMapping Associative Array with field names as the keys and (prefixed) column names as the values
getFilters (   $depth)

The filters are be produced by static getFilter() on the class. The default for that static is to call back getDefaultFilters(). it should add a filter for the label if required. Override the static to get different filters.

Returns
Array of PntSqlFilter the filters by which instances can be searched for
getLabelSort (   $filter = null)
getPeanuts ( )

Returns all the instances of the described class

Returns
Array
Exceptions
PntReflectionError
getPeanutsAccordingTo (   $spec)

Returns the instances of the described class according to the supplied specification

Parameters
PntSqlSpec
Returns
PntObject
Exceptions
PntEror
getPeanutsCount (   $filter)
Returns
int the number of peanuts
Parameters
PntSqlFilter$filterthe filter to apply, or null if none
getPeanutsRunQueryHandler (   $qh,
  $sortPath = null 
)

Returns instances of the described class initialized from the supplied PntQueryHandler

Returns
Array
Exceptions
PntError
getPeanutsWith (   $propertyName,
  $value 
)

Returns the instances of the described class with the specfied property value to be equal to the specfied value

Parameters
StringpropertyName
mixedvalue
Returns
Array $throws PntError
getPeanutWithId (   $id)

Returns the instance of the described class with the id to be equal to the specfied value, or null if none

Parameters
integerid
Returns
PntObject
Exceptions
PntEror
getPersistentFieldPropertyDescriptors ( )
getPersistentRelationPropertyDescriptors (   $type = 'PntDbObject')
getPersistentValuePropertyDescriptors ( )
getSelectQueryHandler ( )
getSelectQueryHandlerFor (   $tableName,
  $tableMap,
  $fieldMapPrefixed 
)
getSimpleQueryHandler ( )
getTableMap ( )

Return an array with the tablenames as keys, in parent first order

getTableName ( )
getVerifyOnDelete ( )
Returns
boolean Wheather some of the multi value properties onDelete = 'v' values recursively if onDelete = 'd'.
initTableMap ( $anArray)

Return an array with table names as keys and class names as values. the first table will be used to obtain the id of new objects, with polymorphic retrieval this table should be the topmost persistent superclass, so that it contains a record for each logical instance in the polymorphism, making the ids unique for all objects within a polymorphism

Returns
Array the map
loadMissingFields (   $peanut,
  $id,
$missingFieldsMap,
  $delegator 
)

Polymorphism support: $peanut has been initialized from data, but some field values where not in the data. Probably the query the data was retrieved with, was created by a superclass' classDescriptor. run another query to retrieve the missing data and initialize the peanut from it. PRECONDITION: $delegator not null

Parameters
PntDbObjectThe peanut that is being retrieved
integer$idThe id of the object
Array$missingFieldsMapWith names of missing fields as keys and columnNames as values
PntClassDescriptor$delegatorThe classDescriptor that issued the original query that resulted in delegation and missing fields
Exceptions
PntError
peanutCached (   $id)
peanutDeleted (   $id)

Register that a peanut has been deleted. The peanut must be removed from the cache.

Parameters
integer$idthe id of the deleted peanut
peanutInserted (   $peanut)

Register that a peanut has been insetred. The peanut must be addes to the cache.

Parameters
PntDbObject$peanutThe peanut that has been inserted
setPolyClassesAllowed (   $map)

set the classes that are allowed for polymorphic persistency

Parameters
array$mapwith the names of the allowed classes as keys and not-null values WARNING: keys with values like false are allowed too!
setPolymorphismPropName (   $value)

Set which property used for polymorphic retrieval If no value, retrieval is monomorphic (default)

Parameters
Stringthe name of the property

Field Documentation

$fieldMap
$peanutsById
$polyClassesAllowed
$polymorphismPropName = null

Name of property that holds class name for polymorhism support

$tableName

The documentation for this class was generated from the following file: