PHP OCI, Oracle and the default number format

When I fetch from an Oracle database using the PHP OCI, numbers that are less than 1 are displayed like .XXXXXX,, for example. .249999. Is there a way to set this to 0.XXXXXXor in any other format without changing every request to use to_char()explicitly? (Perhaps through some session parameters?)

+3
source share
2 answers

It is not possible to execute what you ask globally without changing the php / oci-extension source code. The reason for this behavior is because oaci oci omits 0s in the results and php converts all the results from oci to rows without doing any casting depending on the type of column. Even results in SQL * Plus omit 0 by default, and SQL * Plus formatting must be called set numformatup to configure column formatting and add 0.

There is currently no session change option that you can change to change this behavior.

- is_numeric, number_format sprintf. , php oci, .

0

PHP, 0, float:

$a = '.249999';
echo (float) $a;

$row['number'] = (float) $row['number'];

.

+2

Source: https://habr.com/ru/post/1777047/


All Articles