.

DBFieldBool Class Reference
[Model]

A boolean field im DB. More...

Inheritance diagram for DBFieldBool:
DBField IDBField IPolicyHolder

List of all members.

Public Member Functions

  __construct ($name, $default_value=false, $policy=self::NONE)
  Constructor.
  convert_result ($value)
  Transform result from SELECT to native.
  format_select ()
  Allow replacements for field in select from clause.
  read_from_array ($arr)
  Reads value from array (e.g $_POST) and converts it into something meaningfull.

Protected Member Functions

  do_format_not_null ($value)
  Format values that are not NULL.

Detailed Description

A boolean field im DB.

A Boolean field is an Enum with Values 'TRUE' and 'FALSE'.

Author:
Gerd Riesselmann

Definition at line 10 of file dbfield.bool.cls.php.


Constructor & Destructor Documentation

DBFieldBool::__construct ( name,
default_value = false,
policy = self::NONE  
)

Constructor.

Parameters:
string  $name field name
bool  $default_value Default Value
int  $policy
Returns:
void

Definition at line 19 of file dbfield.bool.cls.php.

00019                                                                                        {
00020                 parent::__construct($name, $default_value, $policy);
00021         }

Member Function Documentation

DBFieldBool::convert_result ( value  ) 

Transform result from SELECT to native.

Parameters:
mixed  $value
Returns:
mixed

Reimplemented from DBField.

Definition at line 50 of file dbfield.bool.cls.php.

00050                                                {
00051                 if (is_string($value)) {
00052                         return in_array(strtoupper($value), array('TRUE', '1'));
00053                 }
00054                 return !empty($value);
00055         }       
DBFieldBool::do_format_not_null ( value  )  [protected]

Format values that are not NULL.

Parameters:
mixed  $value
Returns:
string

Reimplemented from DBField.

Definition at line 29 of file dbfield.bool.cls.php.

00029                                                       {
00030                 if ($value) {
00031                         return $this->quote('TRUE');
00032                 } else { 
00033                         return $this->quote('FALSE');
00034                 }
00035         }
DBFieldBool::format_select (  ) 

Allow replacements for field in select from clause.

Reimplemented from DBField.

Definition at line 40 of file dbfield.bool.cls.php.

00040                                         {
00041                 return '(' . parent::format_select() . " = 'TRUE')";    
00042         }
DBFieldBool::read_from_array ( arr  ) 

Reads value from array (e.g $_POST) and converts it into something meaningfull.

Reimplemented from DBField.

Definition at line 60 of file dbfield.bool.cls.php.

00060                                               {
00061                 $ret = Arr::get_item($arr, $this->get_field_name(), null);
00062                 if (!$this->is_null($ret)) {
00063                         $ret = !empty($ret);
00064                 }
00065                 return $ret;
00066         }

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