reference/mysqli/mysqli/character-set-name.xml
035c126c0393fe154bac46e2c3c489ebadce48a5
...
...
@@ -4,23 +4,23 @@
4
4
<refnamediv>
5
5
<refname>mysqli::character_set_name</refname>
6
6
<refname>mysqli_character_set_name</refname>
7
-
<refpurpose>Returns the default character set for the database connection</refpurpose>
7
+
<refpurpose>Returns the current character set of the database connection</refpurpose>
8
8
</refnamediv>
9
9

10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
12
<para>&style.oop;</para>
13
-
<methodsynopsis role="oop">
14
-
<type>string</type><methodname>mysqli::character_set_name</methodname>
15
-
<void />
13
+
<methodsynopsis role="mysqli">
14
+
<modifier>public</modifier> <type>string</type><methodname>mysqli::character_set_name</methodname>
15
+
<void/>
16
16
</methodsynopsis>
17
17
<para>&style.procedural;</para>
18
18
<methodsynopsis>
19
19
<type>string</type><methodname>mysqli_character_set_name</methodname>
20
-
<methodparam><type>mysqli</type><parameter>link</parameter></methodparam>
20
+
<methodparam><type>mysqli</type><parameter>mysql</parameter></methodparam>
21
21
</methodsynopsis>
22
22
<para>
23
-
Returns the current character set for the database connection.
23
+
Returns the current character set of the database connection.
24
24
</para>
25
25
</refsect1>
26
26

...
...
@@ -35,7 +35,7 @@
35
35

36
36
<refsect1 role="returnvalues">
37
37
&reftitle.returnvalues;
38
-
<para>The default character set for the current connection</para>
38
+
<para>The current character set of the connection</para>
39
39
</refsect1>
40
40

41
41
<refsect1 role="examples">
...
...
@@ -46,49 +46,38 @@
46
46
<programlisting role="php">
47
47
<![CDATA[
48
48
<?php
49
-
/* Open a connection */
49
+

50
+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
50
51
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
51
52

52
-
/* check connection */
53
-
if (mysqli_connect_errno()) {
54
-
printf("Connect failed: %s\n", mysqli_connect_error());
55
-
exit();
56
-
}
53
+
/* Set the default character set */
54
+
$mysqli->set_charset('utf8mb4');
57
55

58
56
/* Print current character set */
59
57
$charset = $mysqli->character_set_name();
60
-
printf ("Current character set is %s\n", $charset);
61
-

62
-
$mysqli->close();
63
-
?>
58
+
printf("Current character set is %s\n", $charset);
64
59
]]>
65
60
</programlisting>
66
61
<para>&style.procedural;</para>
67
62
<programlisting role="php">
68
63
<![CDATA[
69
64
<?php
70
-
/* Open a connection */
71
-
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
72
65

73
-
/* check connection */
74
-
if (!$link) {
75
-
printf("Connect failed: %s\n", mysqli_connect_error());
76
-
exit();
77
-
}
66
+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
67
+
$mysqli = mysqli_connect("localhost", "my_user", "my_password", "world");
78
68

79
-
/* Print current character set */
80
-
$charset = mysqli_character_set_name($link);
81
-
printf ("Current character set is %s\n",$charset);
69
+
/* Set the default character set */
70
+
mysqli_set_charset($mysqli, 'utf8mb4');
82
71

83
-
/* close connection */
84
-
mysqli_close($link);
85
-
?>
72
+
/* Print current character set */
73
+
$charset = mysqli_character_set_name($mysqli);
74
+
printf("Current character set is %s\n", $charset);
86
75
]]>
87
76
</programlisting>
88
77
&examples.outputs;
89
78
<screen>
90
79
<![CDATA[
91
-
Current character set is latin1_swedish_ci
80
+
Current character set is utf8mb4
92
81
]]>
93
82
</screen>
94
83
</example>
...
...
@@ -99,14 +88,12 @@ Current character set is latin1_swedish_ci
99
88
<para>
100
89
<simplelist>
101
90
<member><function>mysqli_set_charset</function></member>
102
-
<member><function>mysqli_client_encoding</function></member>
103
91
<member><function>mysqli_real_escape_string</function></member>
104
92
</simplelist>
105
93
</para>
106
94
</refsect1>
107
95

108
96
</refentry>
109
-

110
97
<!-- Keep this comment at the end of the file
111
98
Local variables:
112
99
mode: sgml
113
100