.

DBFieldInstanceReference Class Reference

A field holding a reference to an instance. More...

Inheritance diagram for DBFieldInstanceReference:
DBFieldText DBField IDBField IPolicyHolder

List of all members.

Public Member Functions

  __construct ($name, $policy=self::NOT_NULL)
  convert_result ($value)
  Transform result from SELECT to native.
  format ($value)
  Reformat passed value to DB format.
  validate ($value)
  Returns true, if the value passed fits the fields restrictions.

Detailed Description

A field holding a reference to an instance.

Definition at line 5 of file dbfield.instancereference.php.


Constructor & Destructor Documentation

DBFieldInstanceReference::__construct ( name,
policy = self::NOT_NULL  
)

Definition at line 6 of file dbfield.instancereference.php.

00006                                                                    {
00007                 parent::__construct($name, 255, null, $policy);
00008         }

Member Function Documentation

DBFieldInstanceReference::convert_result ( value  ) 

Transform result from SELECT to native.

Parameters:
mixed  $value
Returns:
mixed

Reimplemented from DBField.

Definition at line 60 of file dbfield.instancereference.php.

00060                                                {
00061                 $ret = InstanceReferenceSerializier::string_to_instance($value);
00062                 return $ret;
00063         }       
DBFieldInstanceReference::format ( value  ) 

Reformat passed value to DB format.

Parameters:
mixed  $value
Returns:
string

Reimplemented from DBField.

Definition at line 39 of file dbfield.instancereference.php.

00039                                        {
00040                 if (is_null($value)) {
00041                         return parent::format($value);
00042                 }
00043                 
00044                 $value_to_format = '';
00045                 if ($value instanceof IDataObject) {
00046                         $value_to_format = InstanceReferenceSerializier::instance_to_string($value);
00047                 }
00048                 else if (is_string($value)) {
00049                         $value_to_format = $value;
00050                 }
00051                 return parent::format($value_to_format);
00052         }
DBFieldInstanceReference::validate ( value  ) 

Returns true, if the value passed fits the fields restrictions.

Parameters:
mixed  $value
Returns:
Status

Reimplemented from DBFieldText.

Definition at line 16 of file dbfield.instancereference.php.

00016                                          {
00017                 $ret = new Status;
00018                 if (is_null($value)) {
00019                         $ret->merge(parent::validate($value));
00020                 }
00021                 else if (!$value instanceof IDataObject) {
00022                         $ret->append(tr(
00023                                 '%field must be a data object', 
00024                                 'instancereference', 
00025                                 array(
00026                                         '%field' => tr($this->get_field_name(), 'global'),
00027                                 )
00028                         ));                                     
00029                 }
00030                 return $ret;
00031         }

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