protected function _getFieldValue($field, $useDefault = true)
    {
        $fieldOptions = static::$_classFields[get_called_class()][$field];

        if (isset($this->_record[$fieldOptions['columnName']])) {
            $value = $this->_record[$fieldOptions['columnName']];

            // apply type-dependent transformations
            switch ($fieldOptions['type']) {
                case 'password':
                {
                    return $value;
                }

                case 'timestamp':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        if ($value && $value != '0000-00-00 00:00:00') {
                            $this->_convertedValues[$field] = strtotime($value);
                        } else {
                            $this->_convertedValues[$field] = null;
                        }
                    }

                    return $this->_convertedValues[$field];
                }
                case 'serialized':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        $this->_convertedValues[$field] = is_string($value) ? unserialize($value) : $value;
                    }

                    return $this->_convertedValues[$field];
                }
                case 'set':
                case 'list':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        $delim = empty($fieldOptions['delimiter']) ? ',' : $fieldOptions['delimiter'];
                        $this->_convertedValues[$field] = array_filter(preg_split('/\s*'.$delim.'\s*/', $value));
                    }

                    return $this->_convertedValues[$field];
                }

                case 'boolean':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        $this->_convertedValues[$field] = (boolean)$value;
                    }

                    return $this->_convertedValues[$field];
                }

                default:
                {
                    return $value;
                }
            }
        } elseif ($useDefault && isset($fieldOptions['default'])) {
            // return default
            return $fieldOptions['default'];
        } else {
            switch ($fieldOptions['type']) {
                case 'set':
                case 'list':
                {
                    return [];
                }
                default:
                {
                    return null;
                }
            }
        }
    }
protected function _getFieldValue($field, $useDefault = true)
    {
        $fieldOptions = static::$_classFields[get_called_class()][$field];

        if (isset($this->_record[$fieldOptions['columnName']])) {
            $value = $this->_record[$fieldOptions['columnName']];

            // apply type-dependent transformations
            switch ($fieldOptions['type']) {
                case 'password':
                {
                    return $value;
                }

                case 'timestamp':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        if ($value && $value != '0000-00-00 00:00:00') {
                            $this->_convertedValues[$field] = strtotime($value);
                        } else {
                            $this->_convertedValues[$field] = null;
                        }
                    }

                    return $this->_convertedValues[$field];
                }
                case 'serialized':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        $this->_convertedValues[$field] = is_string($value) ? unserialize($value) : $value;
                    }

                    return $this->_convertedValues[$field];
                }
                case 'set':
                case 'list':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        $delim = empty($fieldOptions['delimiter']) ? ',' : $fieldOptions['delimiter'];
                        $this->_convertedValues[$field] = array_filter(preg_split('/\s*'.$delim.'\s*/', $value));
                    }

                    return $this->_convertedValues[$field];
                }

                case 'boolean':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        $this->_convertedValues[$field] = (boolean)$value;
                    }

                    return $this->_convertedValues[$field];
                }

                default:
                {
                    return $value;
                }
            }
        } elseif ($useDefault && isset($fieldOptions['default'])) {
            // return default
            return $fieldOptions['default'];
        } else {
            switch ($fieldOptions['type']) {
                case 'set':
                case 'list':
                {
                    return [];
                }
                default:
                {
                    return null;
                }
            }
        }
    }
protected function _getFieldValue ( $ field , $ useDefault = true ) { $ fieldOptions = static :: $ _classFields [ get_called_class ( ) ] [ $ field ] ; if ( isset ( $ this -> _record [ $ fieldOptions [ 'columnName' ] ] ) ) { $ value = $ this -> _record [ $ fieldOptions [ 'columnName' ] ] ; // apply type-dependent transformations switch ( $ fieldOptions [ 'type' ] ) { case 'password' : { return $ value ; } case 'timestamp' : { if ( ! isset ( $ this -> _convertedValues [ $ field ] ) ) { if ( $ value && $ value != '0000-00-00 00:00:00' ) { $ this -> _convertedValues [ $ field ] = strtotime ( $ value ) ; } else { $ this -> _convertedValues [ $ field ] = null ; } } return $ this -> _convertedValues [ $ field ] ; } case 'serialized' : { if ( ! isset ( $ this -> _convertedValues [ $ field ] ) ) { $ this -> _convertedValues [ $ field ] = is_string ( $ value ) ? unserialize ( $ value ) : $ value ; } return $ this -> _convertedValues [ $ field ] ; } case 'set' : case 'list' : { if ( ! isset ( $ this -> _convertedValues [ $ field ] ) ) { $ delim = empty ( $ fieldOptions [ 'delimiter' ] ) ? ',' : $ fieldOptions [ 'delimiter' ] ; $ this -> _convertedValues [ $ field ] = array_filter ( preg_split ( '/\s*' . $ delim . '\s*/' , $ value ) ) ; } return $ this -> _convertedValues [ $ field ] ; } case 'boolean' : { if ( ! isset ( $ this -> _convertedValues [ $ field ] ) ) { $ this -> _convertedValues [ $ field ] = ( boolean ) $ value ; } return $ this -> _convertedValues [ $ field ] ; } default : { return $ value ; } } } elseif ( $ useDefault && isset ( $ fieldOptions [ 'default' ] ) ) { // return default return $ fieldOptions [ 'default' ] ; } else { switch ( $ fieldOptions [ 'type' ] ) { case 'set' : case 'list' : { return [ ] ; } default : { return null ; } } } }
Retrieves given field's value
@param string $field Name of field
@return mixed value
Retrieves given field s value