PHP Velho Oeste 2024

ingres_field_type

(PHP 4 >= 4.0.2, PHP 5 < 5.1.0, PECL ingres >= 1.0.0)

ingres_field_typeRetourne le type d'un champ dans le résultat d'une requête Ingres

Description

ingres_field_type ( resource $result , int $index ) : string

Retourne le type d'un champ dans le résultat d'une requête.

Note: Configurations connexes

Voir ingres.array_index_start dans la configuration à l'exécution

Liste de paramètres

resultat

La ressource de résultat Ingres

index

index est l'indexe du champ à récupérer.

Les valeurs possibles de index dépendent de la valeur de ingres.array_index_start. Si ingres.array_index_start vaut 1 (par défaut), alors index doit être compris entre 1 et la valeur retournée par la fonction ingres_num_fields(). Si ingres.array_index_start vaut 0, alors index doit être compris entre 0 et la valeur retournée par la fonction ingres_num_fields() - 1.

Valeurs de retour

ingres_field_type() retourne le type d'un champ dans le résultat d'une requête ou FALSE si une erreur survient. Exemples de types renvoyés par cette fonction : IIAPI_BYTE_TYPE, IIAPI_CHA_TYPE, IIAPI_DTE_TYPE, IIAPI_FLT_TYPE, IIAPI_INT_TYPE, IIAPI_VCH_TYPE. Certains de ces types correspondent à plus d'un type SQL, selon la taille du champ (voir ingres_field_length()). Par exemple IIAPI_FLT_TYPE peut être un float4 ou un float8. Pour plus d'informations, voir le OpenAPI User Guide, Appendice C.

Voir aussi

add a note add a note

User Contributed Notes 3 notes

up
1
burckhardtCUTMEOUT at gsf dot de
22 years ago
I have to apologise for the previous two long postings, but information referring to the INGRES data types is a bit hard to find, so I want to share it. Below is my translation script for INGRES->MySQL data types.

<?
// Fieldtype Translator  INGRES => MySQL (c) F.Burckhardt
// translates string, int, date; might be incomplete with respect to other INGRES data-types
$sql="SELECT * FROM table";
$conn = ingres_connect ($database, $user, $password);
$results = ingres_query($sql,$conn);
$fieldtype = array ( "key" => "val");
$ingres_translation = array( "IIAPI_VCH_TYPE" => "string",
                             
"IIAPI_CHA_TYPE" => "string",
                             
"IIAPI_INT_TYPE" => "int",
                             
"IIAPI_DTE_TYPE" => "date");
for(
$i=1; $i<ingres_num_fields($conn)+1; $i++) {
  
$fieldtype [ingres_field_name($i,$conn)] = $ingres_translation[ingres_field_type($i,$conn)];
   echo (
"field_name (".ingres_field_name($i,$conn).") field_type (INGRES): ".ingres_field_type($i,$conn)." => fieldtype (MySQL)".$ingres_translation[ingres_field_type($i,$conn)]." <br>");
        }
?>
up
1
burckhardtCUTMEOUT at gsf dot de
22 years ago
IIAPI_LOGKEY_TYPE A data type with values that are unique within the data source. An application should not attempt to update a column containing a system-maintained object key.

IIAPI_LBYTE_TYPE A variable-length binary string. The actual length of the large byte segment is stored in the first two bytes of the data buffer, followed by the large byte data. Length: 0 to 2,000,000,000 characters.

IIAPI_LVCH_TYPE A variable-length character string. The actual length of the large varchar segment is stored in the first two bytes of the data buffer, followed by the large varchar data. Valid characters for this data type include printing, non-printing, and NULL characters. Trailing blanks are insignificant in a varchar data type. Length: 0 to 2,000,000,000 characters.

IIAPI_MNY_TYPE The Ingres money data type stored in 8 bytes with 2 fixed decimal places.  IIAPI_convertData() or  IIAPI_formatData() can be used to convert to character string or floating point representation.

IIAPI_TABKEY_TYPE A data type with a value that is unique within the table where the table key is stored. An application should not attempt to update a column containing a systemmaintained table key.

IIAPI_TXT_TYPE A variable-length character string. The maximum size for this data type is stored as the ds_length parameter in the corresponding descriptor. The actual length of the text data is stored in the first two bytes of the data buffer, followed by the text data. Valid characters for this data type include printing and non-printing characters. All blanks are significant in a text data buffer. This type is supported for previous Ingres versions; when possible, use  IIAPI_VCH_TYPE. Length: 1 to 2,000 characters.

IIAPI_VBYTE_TYPE A variable-length binary string. The maximum size for varbyte data is stored as the ds_length parameter in the corresponding descriptor. The actual length of the varbyte data is stored in the first two bytes of the data buffer, followed by the varbyte data. Length: 0 to 2,000 characters.

IIAPI_VCH_TYPE A variable-length character string. The maximum size for varchar data is stored as the ds_length parameter in the corresponding descriptor. The actual length of the varchar data is stored in the first two bytes of the data buffer, followed by the varchar data. Trailing blanks are insignificant in a varchar data type. Length: 0 to 2,000 characters.
up
1
burckhardtCUTMEOUT at gsf dot de
22 years ago
Ingres Data Types (oapi.pdf open api user guide)
Data Type Descriptions Ingres data types are described in the following table:
Data Type Description
IIAPI_BYTE_TYPE A fixed length binary string containing data with the declared length. The declared length is stored as the ds_length parameter in the corresponding data descriptor. Length: 1 to 2,000 characters.

IIAPI_CHA_TYPE A fixed length character string that is stored blankpadded to the declared length. The declared length is stored as the ds_length parameter in the corresponding data descriptor. Embedded blanks are significant. Valid characters for this data type include printing, nonprinting, and NULL characters. Length: 1 to 2,000 characters.

IIAPI_CHR_TYPE A fixed length character string that is stored blankpadded to the declared length. The declared length is stored as the ds_length parameter in the corresponding data descriptor. Embedded blanks are insignificant. Valid characters for this data type include printing characters only. This data type is supported for previous Ingres versions; when possible, use IIAPI_CHA_TYPE. Length: 1 to 2,000 characters.

IIAPI_HNDL_TYPE A data type used only by OpenAPI and the application. This data type describes a handle, which is a pointer to one of the control blocks created by OpenAPI. OpenAPI translates the information in the control block into data acceptable by the data source. This data type does not appear in queries.

IIAPI_DEC_TYPE A packed decimal data type stored in 1 to 16 bytes depending on the precision of the value as follows: len = (precision)/2 + 1. IIAPI_convertData() or  IIAPI_formatData() may be used to convert to character string or floating point representation.

IIAPI_DTE_TYPE Ingres internal date data type that is stored in 12 bytes. IIAPI_convertData() or IIAPI_formatData() may be used to convert to character string or floating point representation.

IIAPI_FLT_TYPE A data type supporting data value ranges from - 1.0e+38 to +1.0e+38.

IIAPI_INT_TYPE A data type supporting varying data value ranges. It is dependent on the ds_length of the data value. If the length is 1, the range is from -128 to +127. If the length is 2, the range is from -32,768 to +32,767. If the length is 4, the range is from -2,147,483,648 to +2,147,483,647.
To Top