1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
--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");
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 (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!
|