PHP Doku:: Get information about a field - function.ibase-field-info.html

Verlauf / Chronik / History: (4) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenFirebird/InterBaseFirebird/InterBase Funktionenibase_field_info

Ein Service von Reinhard Neidl - Webprogrammierung.

Firebird/InterBase Funktionen

<<ibase_fetch_row

ibase_free_event_handler>>

ibase_field_info

(PHP 4, PHP 5)

ibase_field_infoGet information about a field

Beschreibung

array ibase_field_info ( resource $result , int $field_number )

Returns an array with information about a field after a select query has been run.

Parameter-Liste

result

An InterBase result identifier.

field_number

Field offset.

Rückgabewerte

Returns an array with the following keys: name, alias, relation, length and type.

Beispiele

Beispiel #1 ibase_field_info() example

<?php
$rs 
ibase_query("SELECT * FROM tablename");
$coln ibase_num_fields($rs);
for (
$i 0$i $coln$i++) {
    
$col_info ibase_field_info($rs$i);
    echo 
"name: "$col_info['name']. "\n";
    echo 
"alias: "$col_info['alias']. "\n";
    echo 
"relation: "$col_info['relation']. "\n";
    echo 
"length: "$col_info['length']. "\n";
    echo 
"type: "$col_info['type']. "\n";
}
?>

Siehe auch


2 BenutzerBeiträge:
- Beiträge aktualisieren...
tiago at econtabil dot com
13.10.2009 16:55
In Firebird 1.5 this function INT64 returned to the fields created as floating point numbers. In Firebird 2.x this function returns as NUMERIC (SIZE, PRECISION). Example: NUMERIC (18,2)

In Brazilian Portuguese:
No Firebird 1.5 esta função retornava INT64 para os campos criados como numéricos com ponto flutuante. No Firebird 2.x esta função retorna como NUMERIC(TAMANHO, PRECISAO). Exemplo: NUMERIC(18,2)
tiago at econtabil dot com
7.04.2006 13:40
Example:
$db = ibase_connect($host,$username,$password, "None", 0, 3 ) or die ('Error trying connect to Database!');

$select = "SELECT * from TABLE";   
$sql = ibase_query($db,$select) or die($select);

$total_fields= ibase_num_fields($sql);

for ($j = 1; $j <= $total_fields; $j++)
  {
    $info_field = ibase_field_info($sql, $j-1 );
    print("Name: " . $info_campo[1]); // print the field name
    print("Type:". $info_campo[4]); //print the field type
    print("Size: " . $info_campo[3]); // print the field size
  }
This function does not return the type from the fields as we are accustomed in interbase.
Example: Fields VARCHAR are returns as VARYING. Fields of the type CHAR return TEXT.

Tested in Firebird 1.5 Super Server.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)