maxdb_character_set_name
maxdb::character_set_name
(PECL maxdb >= 1.0)
maxdb_character_set_name -- maxdb::character_set_name — Returns the default character set for the database connection
说明
过程化风格
maxdb_character_set_name
( resource
$link
) : string面向对象风格
maxdb::character_set_name
( void
) : string
Returns the current character set for the database connection specified by the
link
parameter.
返回值
The default character set for the current connection, either ascii or unicode.
范例
Example #1 面向对象风格
<?php
/* Open a connection */
$maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s\n", maxdb_connect_error());
exit();
}
/* Print current character set */
$charset = $maxdb->character_set_name();
printf ("Current character set is %s\n", $charset);
$maxdb->close();
?>
Example #2 过程化风格
<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", maxdb_connect_error());
exit();
}
/* Print current character set */
$charset = maxdb_character_set_name($link);
printf ("Current character set is %s\n",$charset);
/* close connection */
maxdb_close($link);
?>
以上例程的输出类似于:
Current character set is ascii
参见
- maxdb_client_encoding() - 别名 maxdb_character_set_name
- maxdb_real_escape_string() - Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection