public addKnownField ( string $fieldName, mixed $default = null, string $type = 'integer', boolean $replace = false ) | ||
$fieldName | string | The name of the field |
$default | mixed | Default value, used by reset() (default: null) |
$type | string | Database type for the field. If unsure use 'integer', 'float' or 'text'. |
$replace | boolean | Should we replace an existing known field definition? |
public function addKnownField($fieldName, $default = null, $type = 'integer', $replace = false)
{
if (array_key_exists($fieldName, $this->knownFields) && !$replace) {
return $this;
}
$info = (object) array('Default' => $default, 'Type' => $type);
$this->knownFields[$fieldName] = $info;
// Initialize only the null or not yet set records
if (!isset($this->recordData[$fieldName])) {
$this->recordData[$fieldName] = $default;
}
return $this;
}