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

Inherits PntObject.

Inherited by PntDbObjectTemplate.

Public Member Functions

 __construct ($id=0)
 
 initPropertyDescriptors ()
 
 addDbFieldProps ($includeList=null, $tableName=null)
 
 getLabel ()
 
 getLabelSeparator ()
 
initFromData ($assocArray, &$fieldMap)
 
 initMissingFields (&$missingFieldsMap)
 
 save ()
 
 isNew ()
 
 getSaveErrorMessages ()
 
 checkValueInOptions ($prop, &$errs)
 
 getValueNoOptionErrorMessage ($prop, $value)
 
 getValueWithIdNoOptionErrorMessage ($prop, $id)
 
 getPropsForCheckOptions ()
 
 delete ()
 
 recurseDelete ()
 
 recurseCopyFrom ($original, $fromProp=null)
 
 getPropsForRecurseCopy ($fromProp=null)
 
 copyValuesOf ($prop, $values)
 
 copyFrom ($original, $fromProp=null)
 
 registerCopyFrom ($original)
 
 addVerifyOnDeleteValues (&$result, $exclude=array())
 
 pntDelete ()
 
 getDeleteErrorMessages ($cascading=array())
 
 getOnDeleteProps ($cascading)
 
 getOnDeleteErrorMessage ($prop, $values)
 
 loadData ($id)
 
- Public Member Functions inherited from PntObject
 __construct ()
 
 copy ()
 
 getClass ()
 
 getClassDescriptor ()
 
 initPropertyDescriptors ()
 
 getOid ()
 
 addFieldProp ($name, $type, $readOnly=false, $minValue=null, $maxValue=null, $minLength=0, $maxLength=null, $classDir=null, $persistent=true)
 
 addDerivedProp ($name, $type, $readOnly=true, $minValue=null, $maxValue=null, $minLength=0, $maxLength=null, $classDir=null)
 
 addMultiValueProp ($name, $type, $readOnly=true, $minValue=null, $maxValue=null, $minLength=0, $maxLength=null, $classDir=null)
 
 getPropertyDescriptor ($propertyName)
 
 get ($propertyName, $filter=true)
 
 set ($propertyName, $value)
 
 getOptions ($name, $filter=true)
 
 getValueValidator ($prop)
 
 validateGetErrorString ($prop, $value, $validateReadOnly=true)
 
 basicGetLabel ()
 
 getLabel ()
 
 __toString ()
 
 release ()
 
 getEditInfo ()
 
 toString ()
 
 _getValueValidator ($prop)
 

Static Public Member Functions

static isPersistent ()
 
static getClassDescriptorClass ()
 
static getTableName ()
 
static getFilters ($className, $depth)
 
static getLabelSort ($subclass)
 
static newQueryHandler ()
 
- Static Public Member Functions inherited from PntObject
static isPersistent ()
 
static getClassDescriptorClass ()
 
static getClassDir ()
 
static getClassLabel ()
 
static getUiColumnPaths ()
 
static getReportColumnPaths ()
 
static getUiFieldPaths ($clsDes)
 
static newNavigation ($key, $itemType)
 

Data Fields

 $id = 0
 

Constructor & Destructor Documentation

__construct (   $id = 0)

Constructor Constuctors can not decide what class to instatiate. If subclass has to instanciated depending on the data loaded, implement it in a subclass of PntDbClassDescriptor Therefore this constructor should not be called from framework

Member Function Documentation

addDbFieldProps (   $includeList = null,
  $tableName = null 
)

Adds fieldProperties for the columns from the database. This method assumes column names to be equal to the names of their corresponding field properties.

Parameters
array$includeListnames of properties to include If omitted, all columns will be used in the order they appear in the table, but if a fieldProperty is already defined it is left untouched.
String$tableNamethe name of the table whose columns to use. If omitted, the result of $this->getClassDescriptor()->getTableName() is used
Returns
array propertyDescriptors that where added, by property name
addVerifyOnDeleteValues ( $result,
  $exclude = array() 
)

Add the objects the delete will cascade to

Parameters
array&$resultto add the objects to $this->getDeleteErrorMessages must have been called.
Exceptions
PntError
checkValueInOptions (   $prop,
$errs 
)

Check a property value to be in the options of the property.

Parameters
PntPropertyDescriptor$prop
&array$errs add eventual error message strings to this array
Exceptions
PntError
copyFrom (   $original,
  $fromProp = null 
)

Save this as a new peanut. Assumes this is already cloned and modified. Copy values of multi value properties that are inCopy recursively. Do not copy values of other properties. Saving is done using the basic function pntSacve. If you need to do aditional work that ::save normally does, you need to override this method.

Parameters
PntDbObject$originalwhose multi value properties values may be copied
PntPropertyDescriptor$fromPropthe property recursing from
copyValuesOf (   $prop,
  $values 
)

Copy the values for the property

Parameters
PntMultiValuePropertyDescriptor$propthat will hold the values
arrayof PntObejct $values to be copied
delete ( )

Delete the records of this object from the database. As of version 2.0.alpha the delete recurses to the values of multi value properties whose onDelete is 'd' or 'v'

static getClassDescriptorClass ( )
static
getDeleteErrorMessages (   $cascading = array())

This method is called by ObjectDeleteAction before delete() is called. If the result of this method is not empty, delete() is not called and the error messages are set to the page forwarded to. As of version 2.0.alpha this method adds error messages for multi value properties onDelete = 'c' and recurses for multi value properties onDelete is set

Returns
arrray of String with error messages, or empty array if none
Parameters
arrayof PntObjects $cascading from which the caller is cascading by the paths from each
Exceptions
PntErorr
static getFilters (   $className,
  $depth 
)
static
  • override for special filters
    Returns
    Array of PntSqlFilter the filters by which instances can be searched for
    Parameters
    $classNamename of the subclass - static will be inherited and will not know the name of the class it is called on :-(
getLabel ( )

String representation for representation in UI

Returns
String Default is to return the values of the paths in the labelSort separated by spaces
getLabelSeparator ( )
static getLabelSort (   $subclass)
static

Default implementation - returns sort by defaultLabelProp taken from persistent props

Parameters
string$itemTypeitemType for the sort (may be the sort will be for a subclass)
Returns
PntSqlSort that specifies the sql for sorting the instance records by label
getOnDeleteErrorMessage (   $prop,
  $values 
)
getOnDeleteProps (   $cascading)
getPropsForCheckOptions ( )

Default is to check derived single value properties that are not readOnly

Returns
PntPropertyDescriptor The propertyDescriptor whose values must be in the options
getPropsForRecurseCopy (   $fromProp = null)
Returns
array of PntMultiValuePropertyDescriptor whose values are to be copied recursively
Parameters
PntPropertyDescriptor$fromPropthe property recursing from
getSaveErrorMessages ( )

This method is called by ObjectSaveAction after the properties have been set and before save() is called. If the result of this method is not empty, save is not called and the error messages are set to the page forwarded to.

Returns
arrray of String with error messages, or empty array if none
static getTableName ( )
static
Returns
String the name of the database table the instances are stored in - override for each subclass
getValueNoOptionErrorMessage (   $prop,
  $value 
)
getValueWithIdNoOptionErrorMessage (   $prop,
  $id 
)
& initFromData (   $assocArray,
$fieldMap 
)

Initialize an existing object from an associative array retrieved from the datbase.

Parameters
$assocArrayAssociative Array with the columnNames as keys and the values as values
$fieldMapAssociative Array with the fieldNames as keys and the corresponding columnNames as values
Returns
Associative Array mapping the fields that where not in $assocArray
initMissingFields ( $missingFieldsMap)
initPropertyDescriptors ( )
isNew ( )
static isPersistent ( )
static

Answer wheather the instances can be loaded from and stored in a database.

Returns
boolean;
loadData (   $id)
static newQueryHandler ( )
static
pntDelete ( )
recurseCopyFrom (   $original,
  $fromProp = null 
)

Copy values of multi value properties that are inCopy recursively. Do not copy values of other properties.

Parameters
PntDbObject$originalwhose multi value properties values may be copied
PntPropertyDescriptor$fromPropthe property recursing from, or null if recursion starts here
recurseDelete ( )
registerCopyFrom (   $original)
save ( )
Exceptions
PntError

Field Documentation

$id = 0

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