當前位置: 首頁>>代碼示例>>PHP>>正文


PHP mysqli::get_charset方法代碼示例

本文整理匯總了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;
 }
開發者ID:skrodal,項目名稱:techsmith-relay-api,代碼行數:10,代碼來源:relaymysqlconnection.class.php

示例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);
開發者ID:badlamer,項目名稱:hhvm,代碼行數:11,代碼來源:get_charset.php

示例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);
}
開發者ID:badlamer,項目名稱:hhvm,代碼行數:31,代碼來源:mysqli_fetch_field_oo.php


注:本文中的mysqli::get_charset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。