xref: /PHP-8.2/ext/mysqli/tests/bug74779.phpt (revision b5a14e6c)
1--TEST--
2Bug #74779 (x() and y() truncating floats to integers)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8if (!setlocale(LC_NUMERIC, "de_DE", "de_DE.UTF-8", "de-DE")) die('skip locale not available');
9?>
10--FILE--
11<?php
12require_once("connect.inc");
13
14if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
15    printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
16        $host, $user, $db, $port, $socket);
17}
18
19if (!setlocale(LC_NUMERIC, "de_DE", "de_DE.UTF-8", "de-DE")) {
20    echo "[002] Cannot set locale\n";
21}
22
23if (!$link->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true)) {
24    printf("[003] [%d] %s\n", $link->errno, $link->error);
25}
26
27if (!$result = $link->query("SELECT ST_Y(Point(56.7, 53.34))")) {
28    printf("[004] [%d] %s\n", $link->errno, $link->error);
29}
30
31if (!$array = $result->fetch_array(MYSQLI_ASSOC)) {
32    printf("[005] [%d] %s\n", $link->errno, $link->error);
33}
34
35var_dump($array);
36
37mysqli_close($link);
38?>
39--EXPECT--
40array(1) {
41  ["ST_Y(Point(56.7, 53.34))"]=>
42  float(53.34)
43}
44