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