1--TEST--
2odbc_field_precision(): Getting the precision of the field
3--EXTENSIONS--
4odbc
5--SKIPIF--
6<?php include 'skipif.inc'; ?>
7--FILE--
8<?php
9
10include 'config.inc';
11
12$conn = odbc_connect($dsn, $user, $pass);
13
14odbc_exec($conn, 'CREATE TABLE field_precision (foo INT, bar REAL, baz VARBINARY(50))');
15
16$res = odbc_exec($conn, 'SELECT * FROM field_precision');
17try {
18    odbc_field_precision($res, 0);
19} catch (ValueError $error) {
20    echo $error->getMessage() . "\n";
21}
22var_dump(odbc_field_precision($res, 1));
23var_dump(odbc_field_precision($res, 2));
24var_dump(odbc_field_precision($res, 3));
25var_dump(odbc_field_precision($res, 4));
26
27?>
28--CLEAN--
29<?php
30require 'config.inc';
31$conn = odbc_connect($dsn, $user, $pass);
32odbc_exec($conn, 'DROP TABLE field_precision');
33?>
34--EXPECTF--
35odbc_field_precision(): Argument #2 ($field) must be greater than 0
36int(10)
37int(7)
38int(50)
39
40Warning: odbc_field_precision(): Field index larger than number of fields in %s on line %d
41bool(false)
42