lithium\data\Model::hasField()
Checks to see if a particular field exists in a model's schema. Can check a single field, or return the first field found in an array of multiple options.
Parameters
-
mixed
$field
A single field (string) or list of fields (array) to check the existence of.
Returns
mixedIf $field
is a string, returns a boolean indicating whether or not that field
exists. If $field
is an array, returns the first field found, or false
if none of
the fields in the list are found.
Source
public static function hasField($field) {
if (!is_array($field)) {
return static::schema()->fields($field);
}
foreach ($field as $f) {
if (static::hasField($f)) {
return $f;
}
}
return false;
}