How to check whether a column exists?
Notice: This thread is very old.
- hacafrakus
- Member | 14
The quick solution I have found is this – it is the same method used
internally, since toArray()
is just a $data
property
getter (see https://api.nette.org/…Row.php.html#272).
if (array_key_exists('columnName', $row->toArray())) {
// ...
}
Or using exceptions.
try {
$row->columName;
// ... exists ...
}
catch (Nette\MemberAccessException $e) {
// ... does not exist ...
}