php-src/ext/mysqli/tests/mysqli_query_unicode.phpt
Peter Kokot 113213f027 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:29:24 +02:00

103 lines
3.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--TEST--
mysqli_query() - unicode (cyrillic)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
require_once('table.inc');
if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'utf8'"))
die("skip UTF8 chatset seems not available");
mysqli_free_result($res);
mysqli_close($link);
?>
--FILE--
<?php
include_once("connect.inc");
$tmp = NULL;
$link = NULL;
if (!is_null($tmp = @mysqli_query()))
printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
if (!is_null($tmp = @mysqli_query($link)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
require_once('table.inc');
if (TRUE !== ($tmp = @mysqli_query($link, "set names utf8")))
printf("[002.5] Expecting TRUE, got %s/%s\n", gettype($tmp), $tmp);
if (NULL !== ($tmp = @mysqli_query($link, "SELECT 1 AS колона", MYSQLI_USE_RESULT, "foo")))
printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
if (false !== ($tmp = mysqli_query($link, 'това не е ескюел')))
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if (false !== ($tmp = mysqli_query($link, "SELECT 'това е ескюел, но със обратна наклонена и g'\g")))
printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if ((0 === mysqli_errno($link)) || ('' == mysqli_error($link)))
printf("[006] mysqli_errno()/mysqli_error should return some error\n");
if (!$res = mysqli_query($link, "SELECT 'това ескюел, но с точка и запетая' AS правилен ; "))
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
var_dump(mysqli_fetch_assoc($res));
mysqli_free_result($res);
if (false !== ($res = mysqli_query($link, "SELECT 'това ескюел, но с точка и запетая' AS правилен ; SHOW VARIABLES")))
printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (mysqli_get_server_version($link) > 50000) {
// let's try to play with stored procedures
mysqli_query($link, 'DROP PROCEDURE IF EXISTS процедурка');
if (mysqli_query($link, 'CREATE PROCEDURE процедурка(OUT версия VARCHAR(25)) BEGIN SELECT VERSION() INTO версия; END;')) {
$res = mysqli_query($link, 'CALL процедурка(@version)');
$res = mysqli_query($link, 'SELECT @version AS п_версия');
$tmp = mysqli_fetch_assoc($res);
if (!is_array($tmp) || empty($tmp) || !isset($tmp['п_версия']) || ('' == $tmp['п_версия'])) {
printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link));
var_dump($tmp);
}
mysqli_free_result($res);
} else {
printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
mysqli_query($link, 'DROP FUNCTION IF EXISTS функцийка');
if (mysqli_query($link, 'CREATE FUNCTION функцийка( параметърерсия VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN параметърерсия;')) {
$res = mysqli_query($link, 'SELECT функцийка(VERSION()) AS ф_версия');
$tmp = mysqli_fetch_assoc($res);
if (!is_array($tmp) || empty($tmp) || !isset($tmp['ф_версия']) || ('' == $tmp['ф_версия'])) {
printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link));
var_dump($tmp);
}
mysqli_free_result($res);
} else {
printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
}
mysqli_close($link);
if (false !== ($tmp = mysqli_query($link, "SELECT id FROM test")))
printf("[014] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
print "done!";
?>
--EXPECTF--
array(1) {
["правилен"]=>
string(%d) "това ескюел, но с точка и запетая"
}
Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d
done!