当前位置: 首页>>代码示例>>PHP>>正文


PHP mysql_client_encoding函数代码示例

本文整理汇总了PHP中mysql_client_encoding函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_client_encoding函数的具体用法?PHP mysql_client_encoding怎么用?PHP mysql_client_encoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mysql_client_encoding函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 /**
  * mysql_connect();
  * Connect and select database.
  * @param string The database host. (default 'localhost')
  * @param string The database username. (default 'root')
  * @param string The database user password. (default '')
  * @return boolean true if new connection, false if not. (default false)
  * @param boolean true if persistent connection, false if not. (default false)
  * @param string The database name.
  * @return string The database table prefix. (default '_')
  */
 function connect($db_host = 'localhost', $db_username = 'root', $db_password = '', $new_link_id = false, $pconnect = false, $db_name, $table_prefix = '_')
 {
     // Construct the username and tables prefix.
     $this->db_username = $db_username;
     $this->db_name = $db_name;
     $this->tbl_pre = $table_prefix;
     // Connect to the database.
     if ($pconnect) {
         $this->link_id = @mysql_pconnect($db_host, $db_username, $db_password);
     } else {
         $this->link_id = @mysql_connect($db_host, $db_username, $db_password, $new_link_id);
     }
     if (!$this->link_id) {
         $this->db_error('connect', $db_host);
     }
     // Valid db charset and set custom charset if it defined.
     // Select db.
     if ($this->link_id) {
         $this->valid_charset = @mysql_client_encoding($this->link_id);
         if (defined('DB_CHARSET') && DB_CHARSET != '') {
             $this->query("SET NAMES " . DB_CHARSET);
         }
         if (!@mysql_select_db($this->db_name, $this->link_id)) {
             $this->db_error('select', '');
         } else {
             return $this->link_id;
         }
     }
     unset($db_host, $db_username, $db_password, $new_link_id, $pconnect, $db_name, $table_prefix);
 }
开发者ID:vijay-panchal,项目名称:myAvazonic,代码行数:41,代码来源:db.php

示例2: db_get_encoding

function db_get_encoding($error_checking = true)
{
    global $MySQL;
    $res = mysql_client_encoding($MySQL->link);
    if ($error_checking && !$res) {
        genMySQLErr('Database get encoding error');
    }
    return $res;
}
开发者ID:BackupTheBerlios,项目名称:dolphin-dwbn-svn,代码行数:9,代码来源:db.inc.php

示例3: GetCharSet

 function GetCharSet()
 {
     if (function_exists('mysql_client_encoding')) {
         $this->charSet = @mysql_client_encoding($this->_connectionID);
     }
     if (!$this->charSet) {
         return false;
     } else {
         return $this->charSet;
     }
 }
开发者ID:mczirfusz,项目名称:pkp-lib,代码行数:11,代码来源:adodb-mysql.inc.php

示例4: _doError

 private function _doError()
 {
     if ($this->database->getAdapter()->hasError()) {
         $e = $this->database->getAdapter()->getError();
         $m = array();
         $m[] = 'Database Error : ' . $e->getCode();
         $m[] = 'Message: ' . $e->getMessage();
         $m[] = 'Query: ' . $e->getQuery();
         $m[] = 'Encoding: ' . mysql_client_encoding();
         trigger_error(implode('<br />', $m));
     }
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:12,代码来源:databasemodel.php

示例5: connect

 function connect()
 {
     if ($GLOBALS['db_link']) {
         return;
     }
     profile_point('H2Database:connect() start');
     $GLOBALS['db_link'] = mysql_pconnect(cfg('db/host'), cfg('db/user'), cfg('db/password')) or critical('The database connection to server ' . cfg('db/user') . '@' . cfg('db/host') . ' could not be established (code: ' . @mysql_error($GLOBALS['db_link']) . ')');
     mysql_select_db(cfg('db/database'), $GLOBALS['db_link']) or critical('The database connection to database ' . cfg('db/database') . ' on ' . cfg('db/user') . '@' . cfg('db/host') . ' could not be established. (code: ' . @mysql_error($GLOBALS['db_link']) . ')');
     if (mysql_client_encoding() != 'utf8') {
         mysql_set_charset('utf8');
     }
     profile_point('H2Database:connect() done');
 }
开发者ID:bangnaga,项目名称:HomeOverlord,代码行数:13,代码来源:H2Database.php

示例6: lazyConnect

 protected function lazyConnect()
 {
     $this->connection = mysql_connect($this->host, $this->user, $this->pass);
     if (!$this->connection) {
         throw new MySquirrelException_ConnectionError('Could not connect to ' . $this->host . '.');
     }
     $select_db = mysql_select_db($this->database, $this->connection);
     if (!$select_db) {
         throw new MySquirrelException_ConnectionError('Could not select database ' . $this->database . '.');
     }
     // Attempt to change the character set if necessary.
     if ($this->charset !== false) {
         if (function_exists('mysql_set_charset')) {
             $select_charset = mysql_set_charset($this->charset, $this->connection);
         } elseif (mysql_client_encoding($this->connection) !== $this->charset) {
             $msg = 'Changing the character set requires MySQL 5.0.7 or higher, and PHP 5.2.3 or higher. ';
             $msg .= 'Your database\'s default character set is ' . mysql_client_encoding($this->connection) . '.';
             throw new MySquirrelException_CharacterSetError($msg);
         }
     }
 }
开发者ID:kijin,项目名称:mysquirrel,代码行数:21,代码来源:mysquirrel.php

示例7: __tcSqlLogEnd

function __tcSqlLogEnd($result, $cachedResult = 0)
{
    global $__tcSqlLog, $__tcSqlQueryBeginTime, $__tcSqlLogCount, $__tcPageStartTime;
    static $client_encoding = '';
    $tcSqlQueryEndTime = explode(' ', microtime());
    $elapsed = $tcSqlQueryEndTime[1] - $__tcSqlQueryBeginTime[1] + ($tcSqlQueryEndTime[0] - $__tcSqlQueryBeginTime[0]);
    if (!$client_encoding) {
        $client_encoding = str_replace('_', '-', mysql_client_encoding());
    }
    if ($client_encoding != 'utf8' && function_exists('iconv')) {
        $__tcSqlLog[$__tcSqlLogCount]['error'] = iconv($client_encoding, 'utf-8', mysql_error());
    } else {
        $__tcSqlLog[$__tcSqlLogCount]['error'] = mysql_error();
    }
    $__tcSqlLog[$__tcSqlLogCount]['errno'] = mysql_errno();
    if ($cachedResult == 0) {
        $__tcSqlLog[$__tcSqlLogCount]['elapsed'] = ceil($elapsed * 10000) / 10;
    } else {
        $__tcSqlLog[$__tcSqlLogCount]['elapsed'] = 0;
    }
    $__tcSqlLog[$__tcSqlLogCount]['elapsed'] = sprintf("%4.1f", $__tcSqlLog[$__tcSqlLogCount]['elapsed']);
    $__tcSqlLog[$__tcSqlLogCount]['cached'] = $cachedResult;
    $__tcSqlLog[$__tcSqlLogCount]['rows'] = 0;
    $__tcSqlLog[$__tcSqlLogCount]['endtime'] = $tcSqlQueryEndTime[1] - $__tcPageStartTime[1] + ($tcSqlQueryEndTime[0] - $__tcPageStartTime[0]);
    $__tcSqlLog[$__tcSqlLogCount]['endtime'] = sprintf("%4.1f", ceil($__tcSqlLog[$__tcSqlLogCount]['endtime'] * 10000) / 10);
    if (!$cachedResult && mysql_errno() == 0) {
        switch (strtolower(substr($__tcSqlLog[$__tcSqlLogCount]['sql'], 0, 6))) {
            case 'select':
                $__tcSqlLog[$__tcSqlLogCount]['rows'] = mysql_num_rows($result);
                break;
            case 'insert':
            case 'delete':
            case 'update':
                $__tcSqlLog[$__tcSqlLogCount]['rows'] = mysql_affected_rows();
                break;
        }
    }
    $__tcSqlLogCount++;
    $__tcSqlQueryBeginTime = 0;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:40,代码来源:Debug.php

示例8: Connect

 function Connect($host, $user, $pass)
 {
     error_reporting(null);
     global $CONFIG_mysql_charset;
     $this->link = mysql_connect($host, $user, $pass);
     $GLOBALS['link'] = $this->link;
     if (!$this->link) {
         $this->error_found("01");
     }
     switch ($CONFIG_mysql_charset) {
         case auto:
             $this->charset = mysql_client_encoding($this->link);
             mysql_query("SET NAMES " . $this->charset . "");
             break;
         case disable:
             break;
         default:
             mysql_query("SET NAMES " . $CONFIG_mysql_charset . "");
             break;
     }
     return true;
 }
开发者ID:koeznailbiter,项目名称:Koez-RO-CP,代码行数:22,代码来源:function.php

示例9: connect

 function connect($host = NULL, $user = NULL, $password = NULL, $port = "3306")
 {
     if ($host) {
         $this->_connection['host'] = $host;
     }
     if ($user) {
         $this->_connection['user'] = $user;
     }
     if ($password) {
         $this->_connection['pass'] = $password;
     }
     if ($port) {
         $this->_connection['port'] = $port;
     }
     $this->_connection['id'] = @mysql_connect($this->_connection['host'] . ":" . $this->_connection['port'], $this->_connection['user'], $this->_connection['pass']);
     if (!$this->isConnected()) {
         $this->__error("Error establishing database connection: Check details");
         return false;
     }
     $this->_client_info = mysql_get_client_info();
     $this->_client_encoding = mysql_client_encoding($this->_connection['id']);
     return true;
 }
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:23,代码来源:class.mysql.php

示例10: mysql_client_encoding

    echo "</script>";
}
// include the default language
require_once WB_PATH . '/modules/foldergallery/languages/EN.php';
// check if module language file exists for the language set by the user (e.g. DE, EN)
if (file_exists(WB_PATH . '/modules/foldergallery/languages/' . LANGUAGE . '.php')) {
    require_once WB_PATH . '/modules/foldergallery/languages/' . LANGUAGE . '.php';
}
// Files includen
require_once WB_PATH . '/modules/foldergallery/info.php';
require_once WB_PATH . '/modules/foldergallery/admin/scripts/backend.functions.php';
require_once WB_PATH . '/modules/foldergallery/class/class.upload.php';
require_once WB_PATH . '/modules/foldergallery/class/validator.php';
require_once WB_PATH . '/modules/foldergallery/class/DirectoryHandler.Class.php';
//  Set the mySQL encoding to utf8
$oldMysqlEncoding = mysql_client_encoding();
mysql_set_charset('utf8', $database->db_handle);
$settings = getSettings($section_id);
$root_dir = $settings['root_dir'];
//Chio
if (isset($_GET['cat_id']) && is_numeric($_GET['cat_id'])) {
    $cat_id = $_GET['cat_id'];
} else {
    $error['no_cat_id'] = 1;
    $admin->print_error('lost cat', ADMIN_URL . '/pages/modify.php?page_id=' . $page_id . '&section_id=' . $section_id);
    die;
}
// Kategorie Infos aus der DB holen
$sql = 'SELECT * FROM ' . TABLE_PREFIX . 'mod_foldergallery_categories WHERE id=' . $cat_id . ' LIMIT 1;';
$query = $database->query($sql);
$categorie = $query->fetchRow();
开发者ID:dev4me,项目名称:Foldergallery,代码行数:31,代码来源:modify_cat.php

示例11: doDiagnostics


//.........这里部分代码省略.........
    if (function_exists('gd_info')) {
        $gd_info = gd_info();
        $gd_support = array();
        if ($gd_info['GIF Create Support']) {
            $gd_support[] = 'GIF';
        }
        if ($gd_info['JPG Support']) {
            $gd_support[] = 'JPG';
        }
        if ($gd_info['PNG Support']) {
            $gd_support[] = 'PNG';
        }
        if ($gd_support) {
            $gd_support = join(', ', $gd_support);
        } else {
            $gd_support = gTxt('none');
        }
        $gd = gTxt('gd_info', array('{version}' => $gd_info['GD Version'], '{supported}' => $gd_support));
    } else {
        $gd = gTxt('gd_unavailable');
    }
    if (realpath($prefs['tempdir']) == realpath($prefs['plugin_cache_dir'])) {
        $fail['tmp_plugin_paths_match'] = gTxt('tmp_plugin_paths_match');
    }
    echo pagetop(gTxt('tab_diagnostics'), ''), startTable('list'), tr(td(hed(gTxt('preflight_check'), 1)));
    if ($fail) {
        foreach ($fail as $help => $message) {
            echo tr(tda(nl2br($message) . sp . popHelp($help), ' class="not-ok"'));
        }
    } else {
        echo tr(tda(gTxt('all_checks_passed'), ' class="ok"'));
    }
    echo tr(td(hed(gTxt('diagnostic_info'), 1)));
    $fmt_date = '%Y-%m-%d %H:%M:%S';
    $out = array('<textarea cols="78" rows="18" readonly="readonly" style="width: 500px; height: 300px;">', gTxt('txp_version') . cs . txp_version . ' (' . ($rev ? 'r' . $rev : 'unknown revision') . ')' . n, gTxt('last_update') . cs . gmstrftime($fmt_date, $dbupdatetime) . '/' . gmstrftime($fmt_date, @filemtime(txpath . '/update/_update.php')) . n, gTxt('document_root') . cs . @$_SERVER['DOCUMENT_ROOT'] . ($real_doc_root != @$_SERVER['DOCUMENT_ROOT'] ? ' (' . $real_doc_root . ')' : '') . n, '$path_to_site' . cs . $path_to_site . n, gTxt('txp_path') . cs . txpath . n, gTxt('permlink_mode') . cs . $permlink_mode . n, ini_get('open_basedir') ? 'open_basedir: ' . ini_get('open_basedir') . n : '', ini_get('upload_tmp_dir') ? 'upload_tmp_dir: ' . ini_get('upload_tmp_dir') . n : '', gTxt('tempdir') . cs . $tempdir . n, gTxt('web_domain') . cs . $siteurl . n, getenv('TZ') ? 'TZ: ' . getenv('TZ') . n : '', gTxt('php_version') . cs . phpversion() . n, $is_register_globals ? gTxt('register_globals') . cs . $is_register_globals . n : '', gTxt('gd_library') . cs . $gd . n, gTxt('server_time') . cs . strftime('%Y-%m-%d %H:%M:%S') . n, 'MySQL' . cs . mysql_get_server_info() . n, gTxt('locale') . cs . $locale . n, isset($_SERVER['SERVER_SOFTWARE']) ? gTxt('server') . cs . $_SERVER['SERVER_SOFTWARE'] . n : '', is_callable('apache_get_version') ? gTxt('apache_version') . cs . apache_get_version() . n : '', gTxt('php_sapi_mode') . cs . PHP_SAPI . n, gTxt('rfc2616_headers') . cs . ini_get('cgi.rfc2616_headers') . n, gTxt('os_version') . cs . php_uname('s') . ' ' . php_uname('r') . n, $active_plugins ? gTxt('active_plugins') . cs . join(', ', $active_plugins) . n : '', $fail ? n . gTxt('preflight_check') . cs . n . ln . join("\n", $fail) . n . ln : '', is_readable($path_to_site . '/.htaccess') ? n . gTxt('htaccess_contents') . cs . n . ln . htmlspecialchars(join('', file($path_to_site . '/.htaccess'))) . n . ln : '');
    if ($step == 'high') {
        $mysql_client_encoding = is_callable('mysql_client_encoding') ? mysql_client_encoding() : '-';
        $out[] = n . 'Charset (default/config)' . cs . $mysql_client_encoding . '/' . @$txpcfg['dbcharset'] . n;
        $result = safe_query("SHOW variables like 'character_se%'");
        while ($row = mysql_fetch_row($result)) {
            $out[] = $row[0] . cs . $row[1] . n;
            if ($row[0] == 'character_set_connection') {
                $conn_char = $row[1];
            }
        }
        $table_names = array(PFX . 'textpattern');
        $result = safe_query("SHOW TABLES LIKE '" . PFX . "txp\\_%'");
        while ($row = mysql_fetch_row($result)) {
            $table_names[] = $row[0];
        }
        $table_msg = array();
        foreach ($table_names as $table) {
            $ctr = safe_query("SHOW CREATE TABLE " . $table . "");
            if (!$ctr) {
                unset($table_names[$table]);
                continue;
            }
            $ctcharset = preg_replace('#^CREATE TABLE.*SET=([^ ]+)[^)]*$#is', '\\1', mysql_result($ctr, 0, 'Create Table'));
            if (isset($conn_char) && !stristr($ctcharset, 'CREATE') && $conn_char != $ctcharset) {
                $table_msg[] = "{$table} is {$ctcharset}";
            }
            $ctr = safe_query("CHECK TABLE " . $table);
            if (in_array(mysql_result($ctr, 0, 'Msg_type'), array('error', 'warning'))) {
                $table_msg[] = $table . cs . mysql_result($ctr, 0, 'Msg_Text');
            }
        }
        if ($table_msg == array()) {
            $table_msg = count($table_names) < 18 ? array('-') : array('OK');
        }
        $out[] = count($table_names) . ' Tables' . cs . implode(', ', $table_msg) . n;
        $extns = get_loaded_extensions();
        $extv = array();
        foreach ($extns as $e) {
            $extv[] = $e . (phpversion($e) ? '/' . phpversion($e) : '');
        }
        $out[] = n . gTxt('php_extensions') . cs . join(', ', $extv) . n;
        if (is_callable('apache_get_modules')) {
            $out[] = n . gTxt('apache_modules') . cs . join(', ', apache_get_modules()) . n;
        }
        if (@is_array($pretext_data) and count($pretext_data) > 1) {
            $out[] = n . gTxt('pretext_data') . cs . htmlspecialchars(join('', array_slice($pretext_data, 1, 20))) . n;
        }
        $out[] = n;
        foreach ($files as $f) {
            $rev = '';
            $checksum = '';
            if (is_callable('md5_file')) {
                $checksum = md5_file(txpath . $f);
            }
            if (isset($file_revs[$f])) {
                $rev = $file_revs[$f];
            }
            $out[] = "{$f}" . cs . ($rev ? "r" . $rev : gTxt('unknown')) . ' (' . ($checksum ? $checksum : gTxt('unknown')) . ')' . n;
        }
    }
    $out[] = '</textarea>' . br;
    $dets = array('low' => gTxt('low'), 'high' => gTxt('high'));
    $out[] = form(eInput('diag') . n . gTxt('detail') . cs . selectInput('step', $dets, $step, 0, 1));
    echo tr(td(join('', $out))), endTable();
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:txp_diag.php

示例12: getCharSet

 /**
  * get the used character set.
  * if you didnt manually selected one, the one chosen on the server will
  * be returned
  *
  * @access public
  * @return string
  */
 public function getCharSet()
 {
     if ($this->isConnected()) {
         return mysql_client_encoding($this->_connection);
     } else {
         return $this->dbCharSet;
     }
 }
开发者ID:BlackIkeEagle,项目名称:hersteldienst-devolder,代码行数:16,代码来源:MySql.php

示例13: mysql_connect

Return Values

Returns the default character set name for the current connection. 
*/
require 'MySQLConverterTool/UnitTests/Converter/TestCode/config.php';
$con = mysql_connect($host, $user, $pass);
if (!$con) {
    printf("FAILURE: [%d] %s\n", mysql_errno(), mysql_error());
} else {
    print "SUCCESS: connect\n";
}
if (!mysql_select_db($db, $con)) {
    printf("FAILURE: [%d] %s\n", mysql_errno($con), mysql_error($con));
}
$encoding_default = mysql_client_encoding();
$encoding_con = mysql_client_encoding($con);
if ($encoding_con != $encoding_default) {
    printf("FAILURE: different client encodings reported, [%d] %s\n", mysql_errno($con), mysql_error($con));
} else {
    if (!is_string($encoding_con)) {
        printf("FAILURE: no string returned, [%d] %s\n", mysql_errno($con), mysql_error($con));
    }
}
mysql_close($con);
?>
--EXPECT-EXT/MYSQL-OUTPUT--
SUCCESS: connect

--EXPECT-EXT/MYSQL-PHP-ERRORS--
--EXPECT-EXT/MYSQLI-OUTPUT--
SUCCESS: connect
开发者ID:josenobile,项目名称:MySQLConverterTool,代码行数:31,代码来源:conn_param003.php

示例14: client_encoding

 function client_encoding()
 {
     return mysql_client_encoding($this->connect_id);
 }
开发者ID:Amine12boutouil,项目名称:Kleeja-2.0.0-alpha,代码行数:4,代码来源:mysql.php

示例15: encoding

 /**
  * Gets or sets the encoding for the connection.
  *
  * @param $encoding
  * @return mixed If setting the encoding; returns true on success, else false.
  *         When getting, returns the encoding.
  */
 public function encoding($encoding = null)
 {
     $encodingMap = array('UTF-8' => 'utf8');
     if (empty($encoding)) {
         $encoding = mysql_client_encoding($this->connection);
         return ($key = array_search($encoding, $encodingMap)) ? $key : $encoding;
     }
     $encoding = isset($encodingMap[$encoding]) ? $encodingMap[$encoding] : $encoding;
     return mysql_set_charset($encoding, $this->connection);
 }
开发者ID:WarToaster,项目名称:HangOn,代码行数:17,代码来源:MySql.php


注:本文中的mysql_client_encoding函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。