You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot read the column header or type anymore, it is protected when I use $dbf->getColumns();
I had to use Laravel ReflectionClass and do a whole loop-ta-loop to get the information. LOL
Anyway, if anyone needs a current work around here is a simple way of getting it:
$dbf = new TableReader($dir_file->getPathname());
while ($record = $dbf->nextRecord()) {
$reflectionClass = new ReflectionClass($record);
$properties = $reflectionClass->getProperties();
foreach($properties as $property) {
$property->setAccessible(true); // Make the property accessible if it's protected or private
$value = $property->getValue($record); // This gets the properties to construct the fields
// This checks that value is an object and has header as a property
if (is_object($value) && property_exists($value, 'header')) {
// $value is an object with a 'header' property
for($i=0; $i < count($value->header->columns); $i++ ){
// We do not want the info from the property named header
if($value->header->columns[$i]->name != "header"){
$fieldName = strtoupper($value->header->columns[$i]->name);
$value->header->columns[$i]->type
}
}
}
}
}
Hope this helps others for the moment.
The text was updated successfully, but these errors were encountered:
I cannot read the column header or type anymore, it is protected when I use $dbf->getColumns();
I had to use Laravel ReflectionClass and do a whole loop-ta-loop to get the information. LOL
Anyway, if anyone needs a current work around here is a simple way of getting it:
$dbf = new TableReader($dir_file->getPathname());
while ($record = $dbf->nextRecord()) {
$reflectionClass = new ReflectionClass($record);
$properties = $reflectionClass->getProperties();
foreach($properties as $property) {
$property->setAccessible(true); // Make the property accessible if it's protected or private
$value = $property->getValue($record); // This gets the properties to construct the fields
// This checks that value is an object and has header as a property
if (is_object($value) && property_exists($value, 'header')) {
// $value is an object with a 'header' property
for($i=0; $i < count($value->header->columns); $i++ ){
// We do not want the info from the property named header
if($value->header->columns[$i]->name != "header"){
$fieldName = strtoupper($value->header->columns[$i]->name);
$value->header->columns[$i]->type
}
}
}
}
}
Hope this helps others for the moment.
The text was updated successfully, but these errors were encountered: