Gets list of fields for resource.
array i5_list_fields (resource result/file)
Parameters
| 
   result  | 
  
   Resource describing file or other record set. 
  | 
 
Return
Array containing field names, in order.
| 
   I5_ERR_PHP_HDLDFT  | 
  
   256  | 
  
   No default connection found.  | 
 
| 
   I5_ERR_PHP_OPTIONSTYPE  | 
  
   259  | 
  
   The type of " I5_OPTIONS_ALIAS" option must be x and not x  | 
 
| 
   I5_ERR_PHP_OPTIONSNUMBER  | 
  
   260  | 
  
   Option number -1 is unknown.  | 
 
| 
   I5_ERR_PHP_TYPEPARAM  | 
  
   262  | 
  
   Type of element x in parameter -1 must be y. Type z was provided.  | 
 
Details
Returns an indexed table showing each file field name or SQL request. Table size allows knowing fields number. This number can be known directly using i5_num_fields function.
False is returned if error.
Example
$file = i5_open("EASYCOMXMP/s_customer");
if (is_bool($file))
{
print_r("i5_open error : ".i5_errormsg().'<br/>');
}
else
{
$fields = i5_list_fields($file);
if (is_bool($fields))
{
print_r("i5_list_fields error : ".i5_errormsg().'<br/>');
}
else
{
$nb_fields = count($fields);
echo "s_customer file contains ".$nb_fields." fields.<br/>";
echo "Columns are as follow:<br/>";
for ($i=0; $i < $nb_fields; $i++)
{
$type = i5_field_type($file, $i);
$name = i5_field_name($file, $i);
$len = i5_field_len($file, $i);
if (is_bool($len))
{
print_r("i5_field_len error : ".i5_errormsg().'<br/>');
}
echo $type . " " . $name . " " . $len. '<br/>';
}
}
}
See also