本文整理汇总了PHP中mysqli::get_charset方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::get_charset方法的具体用法?PHP mysqli::get_charset怎么用?PHP mysqli::get_charset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli
的用法示例。
在下文中一共展示了mysqli::get_charset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: db_connect
public function db_connect()
{
$mysqli = new \mysqli($this->config['db_host'], $this->config['db_user'], $this->config['db_pass'], $this->config['db_name']);
//
if ($mysqli->connect_errno) {
Response::error(503, "503 Service Unavailable (DB connection failed): " . $mysqli->connect_error);
}
Utils::log("MySQL DB CONNECTED: " . json_encode($mysqli->get_charset()));
return $mysqli;
}
示例2: getenv
<?php
$host = getenv("MYSQL_TEST_HOST") ? getenv("MYSQL_TEST_HOST") : "localhost";
$port = getenv("MYSQL_TEST_PORT") ? getenv("MYSQL_TEST_PORT") : 3306;
$user = getenv("MYSQL_TEST_USER") ? getenv("MYSQL_TEST_USER") : "root";
$passwd = getenv("MYSQL_TEST_PASSWD") ? getenv("MYSQL_TEST_PASSWD") : "";
$db = getenv("MYSQL_TEST_DB") ? getenv("MYSQL_TEST_DB") : "test";
$mysqli = new mysqli($host, $user, $passwd, $db, $port);
$mysqli->set_charset("utf8");
var_dump($mysqli->get_charset()->charset);
var_dump(mysqli_get_charset($mysqli)->charset);
示例3: mysqli
$tmp = NULL;
$link = NULL;
// Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test
$mysqli = new mysqli();
$res = @new mysqli_result($mysqli);
$test_table_name = 'test_mysqli_fetch_field_oo_table_1';
require 'table.inc';
if (!($mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))) {
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket);
}
// Make sure that client, connection and result charsets are all the
// same. Not sure whether this is strictly necessary.
if (!$mysqli->set_charset('utf8')) {
printf("[%d] %s\n", $mysqli->errno, $mysqli->errno);
}
$charsetInfo = $mysqli->get_charset();
if (!($res = $mysqli->query("SELECT id AS ID, label FROM test_mysqli_fetch_field_oo_table_1 AS TEST ORDER BY id LIMIT 1"))) {
printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error);
}
var_dump($res->fetch_field());
$tmp = $res->fetch_field();
var_dump($tmp);
if ($tmp->charsetnr != $charsetInfo->number) {
printf("[005] Expecting charset %s/%d got %d\n", $charsetInfo->charset, $charsetInfo->number, $tmp->charsetnr);
}
if ($tmp->length != $charsetInfo->max_length) {
printf("[006] Expecting length %d got %d\n", $charsetInfo->max_length, $tmp->max_length);
}
if ($tmp->db != $db) {
printf("[007] Expecting database '%s' got '%s'\n", $db, $tmp->db);
}