略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: oci_field_precision

2024-04-26

oci_field_precision

(PHP 5, PHP 7, PHP 8, PECL OCI8 >= 1.1.0)

oci_field_precision返回字段精度

说明

oci_field_precision(resource $statement, int $field): int

返回索引为 field(从 1 开始)的字段的精度。

对于 FLOAT 字段,精度为非零值且范围为 -127。如果精度为 0,则字段为 NUMBER。其它类型为 NUMBER(precision, scale)。

注意:

在 PHP 5.0.0 之前的版本必须使用 ocicolumnprecision() 替代本函数。该函数名仍然可用,为向下兼容作为 oci_field_precision() 的别名。不过其已被废弃,不推荐使用。

参见 oci_field_scale()oci_field_type()

add a noteadd a note

User Contributed Notes 2 notes

up
1
webmaster at smwebdesigns dot com
14 years ago
I did not test well before posting previous code.  This if statement works and the other does not.

if( ocicolumnscale($R, $i ) != 129 )
{
    $int_decimal = ocicolumnscale($R, $i );
    $int_length = ocicolumnprecision($R, $i) - $int_decimal;
}
up
1
webmaster at smwebdesigns dot com
14 years ago
I've found that when using ocicolumnprecision or oci_field_precision it will not show you the decimal places if you are are reading from tables with decimals.  You can use ocicolumnscale or oci_field_scale to find the decimal.

if( ocicolumnscale($R, $i ) > 0 )
{
    $int_decimal = ocicolumnscale($R, $i );
    $int_length = ocicolumnprecision($R, $i) - $int_decimal;
}

官方地址:https://www.php.net/manual/en/function.oci-field-precision.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3