English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP odbc_field_scale() Function Usage and Example

PHP ODBC Reference Manual

The odbc_field_scale() function retrieves the number of decimal places of the field.

Syntax

int odbc_field_scale( resource $result_id, int $field_number )

Definition and Usage

Get the number of decimal places of the field to get the number of decimal places of the floating-point number.

Return Value

Returns the number of decimal places of the field as an integer, or False if an error occurs.

Parameter

NumberParameters and Description
1

result_id

Result Identifier

2

field_number

Field Number. The field number starts from1Start.

Example

Try the following example

<?php
   $input_ID = odbc_connect("DSN", "user_id", "pass_id");
   $sql = "SELECT * FROM Products";
   $result = odbc_exec($input_ID, $sql);
   
   odbc_fetch_row($result);
   
   for ($col = 1; $col <= odbc_num_fields($result); $col++) {
      printf("Column %s has scale %s\n", odbc_field_name($result, $col), odbc_field_scale($result, $col));
   }
?>

PHP ODBC Reference Manual