*/
function getField ($fieldName);
+ /**
+ * Checks if given field is set
+ *
+ * @param $fieldName Field name to check
+ * @return $isSet Whether the given field name is set
+ * @throws NullPointerException If the result instance is null
+ */
+ function isFieldSet ($fieldName);
+
/**
* Checks whether an object equals this object. You should overwrite this
* method to implement own equality checks
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, TRUE).'</pre>');
// Convert dashes to underscore
- $fieldName = $this->convertDashesToUnderscores($fieldName);
+ $fieldName2 = $this->convertDashesToUnderscores($fieldName);
// Does the field exist?
- if (isset($fieldArray[$fieldName])) {
+ if ($this->isFieldSet($fieldName)) {
// Get it
- $fieldValue = $fieldArray[$fieldName];
+ $fieldValue = $fieldArray[$fieldName2];
} elseif (defined('DEVELOPER')) {
// Missing field entry, may require debugging
self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray<pre>=' . print_r($fieldArray, TRUE) . '</pre>,fieldName=' . $fieldName . ' not found!');
return $fieldValue;
}
+ /**
+ * Checks if given field is set
+ *
+ * @param $fieldName Field name to check
+ * @return $isSet Whether the given field name is set
+ * @throws NullPointerException If the result instance is null
+ */
+ public function isFieldSet ($fieldName) {
+ // Get result instance
+ $resultInstance = $this->getResultInstance();
+
+ // Is this instance null?
+ if (is_null($resultInstance)) {
+ // Then the user instance is no longer valid (expired cookies?)
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
+
+ // Get current array
+ $fieldArray = $resultInstance->current();
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=<pre>'.print_r($fieldArray, TRUE).'</pre>');
+
+ // Convert dashes to underscore
+ $fieldName = $this->convertDashesToUnderscores($fieldName);
+
+ // Determine it
+ $isSet = isset($fieldArray[$fieldName]);
+
+ // Return result
+ return $isSet;
+ }
+
/**
* Flushs all pending updates to the database layer
*
* @throws NullPointerException Thrown if $valueInstance is null
*/
public function getValueField ($fieldName) {
+ // Init value
+ $fieldValue = NULL;
+
// The $valueInstance attribute should not be null!
if (is_null($this->getValueInstance())) {
// Throws an exception here
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
} // END - if
- // Get the field value
- $fieldValue = $this->getValueInstance()->getField($fieldName);
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - BEFORE!');
-
- // Is it null?
- if ((is_null($fieldValue)) && (!is_null($this->extraInstance))) {
+ // Is the field set?
+ if ($this->getValueInstance()->isFieldSet($fieldName)) {
+ // Get the field value
+ $fieldValue = $this->getValueInstance()->getField($fieldName);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Value instance!');
+ } elseif ((!is_null($this->extraInstance)) && ($this->extraInstance->isFieldSet($fieldName))) {
// So try the extra instance
$fieldValue = $this->extraInstance->getField($fieldName);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Extra instance!');
+ } else {
+ // Field is not set
+ if ((!is_null($this->extraInstance)) && ($fieldName == 'city_name')) die('<pre>'.print_r($this->extraInstance, TRUE).'</pre>');
+ $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] fieldName=' . $fieldName . ' is not set! - @TODO');
} // END - if
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - AFTER!');
// Return it
return $fieldValue;
// Our super interface "FrameworkInterface" requires this
}
+ /**
+ * Checks if given field is set
+ *
+ * @param $fieldName Field name to check
+ * @return $isSet Whether the given field name is set
+ * @throws NullPointerException If the result instance is null
+ */
+ public function isFieldSet ($fieldName) {
+ // Our super interface "FrameworkInterface" requires this
+ }
+
/**
* Generates a code for hashes from this class
*