当前位置: 首页>>代码示例>>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;未经允许,请勿转载。