DBFieldFloat Class Reference
[Model]
Inheritance diagram for DBFieldFloat:
Public Member Functions |
|
__construct ($name, $default_value=0, $policy=self::NOT_NULL) | |
read_from_array ($arr) | |
Reads value from array (e.g $_POST) and
converts it into something meaningfull. |
|
validate ($value) | |
Returns true, if the value passed fits the
fields restrictions. |
|
Public Attributes |
|
const | UNSIGNED = 2 |
Protected Member Functions |
|
do_format_not_null ($value) | |
Format values that are not NULL. |
Detailed Description
A float field in DB.
Definition at line 8 of file dbfield.float.cls.php.
Constructor & Destructor Documentation
DBFieldFloat::__construct | ( | $ | name, | |
$ | default_value = 0 , |
|||
$ | policy =
self::NOT_NULL |
|||
) |
Definition at line 11 of file dbfield.float.cls.php.
00011 { 00012 parent::__construct($name, $default_value, $policy); 00013 }
Member Function Documentation
DBFieldFloat::do_format_not_null | ( | $ | value | ) | [protected] |
Format values that are not NULL.
- Parameters:
-
mixed $value
- Returns:
- string
Reimplemented from DBField.
Definition at line 60 of file dbfield.float.cls.php.
DBFieldFloat::read_from_array | ( | $ | arr | ) |
Reads value from array (e.g $_POST) and converts it into something meaningfull.
Reimplemented from DBField.
Definition at line 67 of file dbfield.float.cls.php.
00067 { 00068 $ret = parent::read_from_array($arr); 00069 if (!empty($ret)) { 00070 $ret = String::delocalize_number($ret); 00071 } 00072 return $ret; 00073 }
DBFieldFloat::validate | ( | $ | value | ) |
Returns true, if the value passed fits the fields restrictions.
- Parameters:
-
string $value
- Returns:
- Status
Reimplemented from DBField.
Definition at line 21 of file dbfield.float.cls.php.
00021 { 00022 if ($value === '') { 00023 $value = null; 00024 } 00025 00026 $ret = parent::validate($value); 00027 00028 if ($ret->is_ok() && !is_null($value)) { 00029 if ($this->has_policy(self::UNSIGNED)) { 00030 if (!Validation::is_double($value, 0)) { 00031 $ret->append(tr( 00032 '%field must be a positive number', 00033 'core', 00034 array( 00035 '%field' => $this->get_field_name_translation() 00036 ) 00037 )); 00038 } 00039 } 00040 else if (!Validation::is_double($value)) { 00041 $ret->append(tr( 00042 '%field must be a number', 00043 'core', 00044 array( 00045 '%field' => tr($this->get_field_name(), 'global'), 00046 ) 00047 )); 00048 } 00049 } 00050 00051 return $ret; 00052 }
Member Data Documentation
const DBFieldFloat::UNSIGNED = 2 |
Definition at line 9 of file dbfield.float.cls.php.
The documentation for this class was generated from the following file:
- gyro/core/model/base/fields/dbfield.float.cls.php