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


PHP pg_client_encoding函数代码示例

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


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

示例1: OA_Dal_Delivery_connect

/**
 * The function to open a database connection, or return the resource if already open
 *
 * @param string $database   The name of the database config to use
 *                           (Must match the database section name in the conf file)
 * @return resource|false    The PgSQL database resource
 *                           or false on failure
 */
function OA_Dal_Delivery_connect($database = 'database')
{
    // If a connection already exists, then return that
    if ($database == 'database' && isset($GLOBALS['_MAX']['ADMIN_DB_LINK']) && is_resource($GLOBALS['_MAX']['ADMIN_DB_LINK'])) {
        return $GLOBALS['_MAX']['ADMIN_DB_LINK'];
    } elseif ($database == 'rawDatabase' && isset($GLOBALS['_MAX']['RAW_DB_LINK']) && is_resource($GLOBALS['_MAX']['RAW_DB_LINK'])) {
        return $GLOBALS['_MAX']['RAW_DB_LINK'];
    }
    // No connection exists, so create one
    $conf = $GLOBALS['_MAX']['CONF'];
    if (!empty($conf[$database])) {
        $dbConf = $conf[$database];
    } else {
        $dbConf = $conf['database'];
    }
    $dbParams = array();
    $dbParams[] = 'port=' . (isset($dbConf['port']) ? $dbConf['port'] : 5432);
    $dbParams[] = !empty($dbConf['protocol']) && $dbConf['protocol'] == 'unix' ? '' : 'host=' . $dbConf['host'];
    $dbParams[] = empty($dbConf['username']) ? '' : 'user=' . $dbConf['username'];
    $dbParams[] = empty($dbConf['password']) ? '' : 'password=' . $dbConf['password'];
    $dbParams[] = 'dbname=' . $dbConf['name'];
    if ($dbConf['persistent']) {
        $dbLink = @pg_pconnect(join(' ', $dbParams));
    } else {
        $dbLink = @pg_connect(join(' ', $dbParams));
    }
    if ($dbLink && !empty($conf['databasePgsql']['schema'])) {
        @pg_query($dbLink, "SET search_path='{$conf['databasePgsql']['schema']}'");
    }
    if ($dbLink && !empty($conf['databaseCharset']['checkComplete']) && !empty($conf['databaseCharset']['clientCharset'])) {
        @pg_client_encoding($dbLink, $conf['databaseCharset']['clientCharset']);
    }
    return $dbLink;
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:42,代码来源:pgsql.php

示例2: castLink

 public static function castLink($link, array $a, Stub $stub, $isNested)
 {
     $a['status'] = pg_connection_status($link);
     $a['status'] = new ConstStub(PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']);
     $a['busy'] = pg_connection_busy($link);
     $a['transaction'] = pg_transaction_status($link);
     if (isset(self::$transactionStatus[$a['transaction']])) {
         $a['transaction'] = new ConstStub(self::$transactionStatus[$a['transaction']], $a['transaction']);
     }
     $a['pid'] = pg_get_pid($link);
     $a['last error'] = pg_last_error($link);
     $a['last notice'] = pg_last_notice($link);
     $a['host'] = pg_host($link);
     $a['port'] = pg_port($link);
     $a['dbname'] = pg_dbname($link);
     $a['options'] = pg_options($link);
     $a['version'] = pg_version($link);
     foreach (self::$paramCodes as $v) {
         if (false !== ($s = pg_parameter_status($link, $v))) {
             $a['param'][$v] = $s;
         }
     }
     $a['param']['client_encoding'] = pg_client_encoding($link);
     $a['param'] = new EnumStub($a['param']);
     return $a;
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:26,代码来源:PgSqlCaster.php

示例3: my_PGSQL_db_connect

function my_PGSQL_db_connect()
{
    // http://www.php.net/manual/ru/ref.pgsql.php
    $dblocation = "localhost";
    $dbuser = "root";
    $dbpassword = "";
    $dbname = "bacula";
    /*$db = pg_connect("host='$dblocation' dbname='$dbname' user='$dbuser' password='$dbpassword'")
      or die("[PGSQL]" . pg_last_error());*/
    $db = pg_connect("host='{$dblocation}' dbname='{$dbname}' user='{$dbuser}' password='{$dbpassword}'") or die("[PGSQL]" . pg_last_error());
    pg_set_client_encoding($db, 'SQL_ASCII');
    echo "Connect [PGSQL] ", $dbname, ". Encoding ", pg_client_encoding(), ".  OK.\n";
    return $db;
}
开发者ID:neverstoplwy,项目名称:contrib-webacula,代码行数:14,代码来源:bacula_DBcopy_MySQL2PGSQL.php

示例4: __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('_', '-', pg_client_encoding());
    }
    //	if( $client_encoding != 'utf8' && function_exists('iconv') ) {
    //		$__tcSqlLog[$__tcSqlLogCount]['error'] = iconv( $client_encoding, 'utf-8', pg_last_error());
    //	}
    //	else {
    $__tcSqlLog[$__tcSqlLogCount]['error'] = pg_last_error();
    //	}
    $__tcSqlLog[$__tcSqlLogCount]['errno'] = 0;
    //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'] = pg_num_rows($result);
                break;
            case 'insert':
            case 'delete':
            case 'update':
                $__tcSqlLog[$__tcSqlLogCount]['rows'] = pg_affected_rows($result);
                break;
        }
    }
    $__tcSqlLogCount++;
    $__tcSqlQueryBeginTime = 0;
}
开发者ID:Avantians,项目名称:Textcube,代码行数:43,代码来源:Debug.php

示例5: conn

function conn()
{
    //echo $_SERVER['SERVER_NAME'];
    /*if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
    			// SSL connection
    			$descriptor = fopen("https://".$_SERVER['SERVER_NAME']."/conexion.conf","r") or sysError("conectaBD.abriendo Archivo de configuracion");
    		}
    		else{
    			$descriptor = fopen("http://".$_SERVER['SERVER_NAME']."/conexion.conf","r") or sysError("conectaBD.abriendo Archivo de configuracion");
    		}*/
    $descriptor = fopen("http://localhost/jornadasgvsig/conexion.conf", "r");
    $i = 0;
    while (!feof($descriptor)) {
        $buffer = fgets($descriptor, 50);
        if ($i == 0) {
            $dbname = substr($buffer, 3, -1);
        }
        if ($i == 1) {
            $dbuser = substr($buffer, 3, -1);
        }
        if ($i == 2) {
            $dbuserpass = substr($buffer, 3, -1);
        }
        if ($i == 3) {
            $dbhost = substr($buffer, 3, -1);
        }
        if ($i == 4) {
            $dbport = substr($buffer, 3, -1);
        }
        $i++;
    }
    $conn = "host={$dbhost} port={$dbport} dbname={$dbname} user={$dbuser} password={$dbuserpass} ";
    $connDebug = "host={$dbhost} port={$dbport} dbname={$dbname} user={$dbuser} password=xxxxxx ";
    $conexion = pg_connect($conn) or sysError("conectaBD.pg_connect->{$connDebug}");
    $encoding = pg_client_encoding($conexion);
    pg_set_client_encoding($conexion, "UTF8");
    return $conexion;
}
开发者ID:snake77se,项目名称:jornadasgvsig,代码行数:38,代码来源:conectaBD.php

示例6: get_charset

 public function get_charset()
 {
     $r = new stdClass();
     $r->charset = pg_client_encoding($this->connection);
     # pg_parameter_status($this->connection, 'server_encoding')
     $r->collation = null;
     $r->comment = 'UTF-8 Unicode';
     $r->dir = '';
     $r->min_length = 1;
     $r->max_length = 3;
     $r->number = 33;
     $r->state = 993;
     return $r;
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:14,代码来源:pgsql.php

示例7: backup

 public static function backup($database, $tables, $filename, $structure = true, $data = true, $drop = true, $compress = true, $full = false)
 {
     global $db;
     $schema = $database;
     if (!is_array($tables) || empty($tables)) {
         trigger_error('No tables to backup', E_USER_WARNING);
         return false;
     }
     $crlf = "\n";
     $current_user = $db->sql_ufetchrowset('SELECT CURRENT_USER', SQL_NUM);
     $current_user = $current_user[0][0];
     //$search_path = $db->sql_ufetchrowset('SELECT current_schemas(true)');
     //$search_path = preg_replace('#^{(.*?)}$#', '\\1', $search_path[0][0]);
     # doing some DOS-CRLF magic...
     # this looks better under WinX
     if (preg_match('#[^(]*\\((.*)\\)[^)]*#', $_SERVER['HTTP_USER_AGENT'], $regs)) {
         if (false !== stripos($regs[1], 'Win')) {
             $crlf = "\r\n";
         }
     }
     if (GZIPSUPPORT) {
         while (ob_end_clean()) {
         }
         header('Content-Encoding: ');
     } else {
         $compress = false;
     }
     if ($compress) {
         $filename .= '.gz';
         header("Content-Type: application/x-gzip; name=\"{$filename}\"");
     } else {
         header("Content-Type: text/x-delimtext; name=\"{$filename}\"");
     }
     header("Content-disposition: attachment; filename={$filename}");
     $controls = "--{$crlf}-- PostgreSQL dump : {$database}{$crlf}" . "-- " . _ON . " " . formatDateTime(time(), _DATESTRING) . " !{$crlf}--{$crlf}{$crlf}" . "SET client_encoding = '" . pg_client_encoding() . "';{$crlf}" . "SET check_function_bodies = false;{$crlf}" . "SET SESSION AUTHORIZATION '{$current_user}';{$crlf}{$crlf}";
     if ($full) {
         if ($drop) {
             $controls .= 'DROP SCHEMA ' . $schema . ' CASCADE;' . $crlf;
         }
         $controls .= "CREATE SCHEMA {$schema} AUTHORIZATION {$current_user};{$crlf}" . "REVOKE ALL ON SCHEMA {$schema} FROM PUBLIC;{$crlf}" . 'ALTER USER ' . $current_user . ' SET search_path TO ' . $schema . ";{$crlf}" . "{$crlf}";
     }
     DBCtrl::output($controls, $compress);
     set_time_limit(0);
     if ($drop && !$full) {
         SQLCtrl::drop_table_struct($schema, $tables, $crlf, $compress);
     }
     if ($structure) {
         if ($full) {
             DBCtrl::output(SQLCtrl::get_function($schema, $crlf), $compress);
         }
         SQLCtrl::get_table_struct($schema, $tables, $crlf, $compress);
     }
     if ($data) {
         SQLCtrl::get_table_content($schema, $tables, $crlf, false, $compress);
     }
     if ($structure) {
         SQLCtrl::get_index($schema, $tables, $crlf, $compress);
         DBCtrl::output(SQLCtrl::get_sequence($schema, $tables, $crlf, $full), $compress);
     }
     DBCtrl::output($crlf . 'VACUUM ANALYZE;', $compress);
     if ($compress) {
         DBCtrl::output('', true, true);
     }
     exit;
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:65,代码来源:postgresql.php

示例8: get_details

 public function get_details()
 {
     $details = $this->get_versions();
     $details['unicode'] = true;
     $details['character_set_client'] = pg_client_encoding();
     return $details;
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:7,代码来源:postgresql.php

示例9: getConnectionCollation

 /**
  * Method to get the database connection collation, as reported by the driver. If the connector doesn't support
  * reporting this value please return an empty string.
  *
  * @return  string
  */
 public function getConnectionCollation()
 {
     return pg_client_encoding($this->connection);
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:10,代码来源:postgresql.php

示例10: connect

 /**
  * Connect to db
  * Must be called before other methods.
  * @param string $dbhost The database host.
  * @param string $dbuser The database username.
  * @param string $dbpass The database username's password.
  * @param string $dbname The name of the database being connected to.
  * @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
  * @param array $dboptions driver specific options
  * @return bool true
  * @throws dml_connection_exception if error
  */
 public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions = null)
 {
     if ($prefix == '' and !$this->external) {
         //Enforce prefixes for everybody but mysql
         throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
     }
     $driverstatus = $this->driver_installed();
     if ($driverstatus !== true) {
         throw new dml_exception('dbdriverproblem', $driverstatus);
     }
     $this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
     $pass = addcslashes($this->dbpass, "'\\");
     // Unix socket connections should have lower overhead
     if (!empty($this->dboptions['dbsocket']) and ($this->dbhost === 'localhost' or $this->dbhost === '127.0.0.1')) {
         $connection = "user='{$this->dbuser}' password='{$pass}' dbname='{$this->dbname}'";
         if (strpos($this->dboptions['dbsocket'], '/') !== false) {
             // A directory was specified as the socket location.
             $connection .= " host='" . $this->dboptions['dbsocket'] . "'";
         }
         if (!empty($this->dboptions['dbport'])) {
             // A port as specified, add it to the connection as it's used as part of the socket path.
             $connection .= " port ='" . $this->dboptions['dbport'] . "'";
         }
     } else {
         $this->dboptions['dbsocket'] = '';
         if (empty($this->dbname)) {
             // probably old style socket connection - do not add port
             $port = "";
         } else {
             if (empty($this->dboptions['dbport'])) {
                 $port = "port ='5432'";
             } else {
                 $port = "port ='" . $this->dboptions['dbport'] . "'";
             }
         }
         $connection = "host='{$this->dbhost}' {$port} user='{$this->dbuser}' password='{$pass}' dbname='{$this->dbname}'";
     }
     if (empty($this->dboptions['dbhandlesoptions'])) {
         // ALTER USER and ALTER DATABASE are overridden by these settings.
         $options = array('--client_encoding=utf8', '--standard_conforming_strings=on');
         // Select schema if specified, otherwise the first one wins.
         if (!empty($this->dboptions['dbschema'])) {
             $options[] = "-c search_path=" . addcslashes($this->dboptions['dbschema'], "'\\");
         }
         $connection .= " options='" . implode(' ', $options) . "'";
     }
     ob_start();
     if (empty($this->dboptions['dbpersist'])) {
         $this->pgsql = pg_connect($connection, PGSQL_CONNECT_FORCE_NEW);
     } else {
         $this->pgsql = pg_pconnect($connection, PGSQL_CONNECT_FORCE_NEW);
     }
     $dberr = ob_get_contents();
     ob_end_clean();
     $status = pg_connection_status($this->pgsql);
     if ($status === false or $status === PGSQL_CONNECTION_BAD) {
         $this->pgsql = null;
         throw new dml_connection_exception($dberr);
     }
     if (!empty($this->dboptions['dbhandlesoptions'])) {
         /* We don't trust people who just set the dbhandlesoptions, this code checks up on them.
          * These functions do not talk to the server, they use the client library knowledge to determine state.
          */
         if (!empty($this->dboptions['dbschema'])) {
             throw new dml_connection_exception('You cannot specify a schema with dbhandlesoptions, use the database to set it.');
         }
         if (pg_client_encoding($this->pgsql) != 'UTF8') {
             throw new dml_connection_exception('client_encoding = UTF8 not set, it is: ' . pg_client_encoding($this->pgsql));
         }
         if (pg_escape_string($this->pgsql, '\\') != '\\') {
             throw new dml_connection_exception('standard_conforming_strings = on, must be set at the database.');
         }
     }
     // Connection stabilised and configured, going to instantiate the temptables controller
     $this->temptables = new pgsql_native_moodle_temptables($this);
     return true;
 }
开发者ID:janeklb,项目名称:moodle,代码行数:89,代码来源:pgsql_native_moodle_database.php

示例11: getAttribute

 public function getAttribute($attribute, &$source = null, $func = 'PDO::getAttribute', &$last_error = null)
 {
     switch ($attribute) {
         case PDO::ATTR_AUTOCOMMIT:
             return $this->autocommit;
             break;
         case PDO::ATTR_CLIENT_VERSION:
             $ver = pg_version($this->link);
             return $ver['client'];
             break;
         case PDO::ATTR_CONNECTION_STATUS:
             if (pg_connection_status($this->link) === PGSQL_CONNECTION_OK) {
                 return 'Connection OK; waiting to send.';
             } else {
                 return 'Connection BAD';
             }
             break;
         case PDO::ATTR_SERVER_INFO:
             return sprintf('PID: %d; Client Encoding: %s; Is Superuser: %s; Session Authorization: %s; Date Style: %s', pg_get_pid($this->link), pg_client_encoding($this->link), pg_parameter_status($this->link, 'is_superuser'), pg_parameter_status($this->link, 'session_authorization'), pg_parameter_status($this->link, 'DateStyle'));
             break;
         case PDO::ATTR_SERVER_VERSION:
             return pg_parameter_status($this->link, 'server_version');
             break;
         default:
             return parent::getAttribute($attribute, $source, $func, $last_error);
             break;
     }
 }
开发者ID:PHPcomaptibility,项目名称:PHPPDO,代码行数:28,代码来源:pgsql.php

示例12: connect

 /**
  * Opens a connection to the SQL server
  *
  * Opens a connection to the SQL server, checking for connection errors,
  * and performs a ROLLBACK to make sure any old transaction is cleared.
  *
  * @param bool $force Whether to force a new connection.
  * @return bool true on success, false on error
  * @access public
  */
 public function connect($force = false)
 {
     $constr = '';
     if (empty($this->_socket)) {
         if (!empty($this->_hostname)) {
             $constr .= " host={$this->_hostname}";
         }
         if (!empty($this->_port)) {
             $constr .= " port={$this->_port}";
         }
     }
     if (!empty($this->_username)) {
         $constr .= " user={$this->_username}";
     }
     if (!empty($this->_password)) {
         $constr .= " password={$this->_password}";
     }
     if (!empty($this->_database)) {
         $constr .= " dbname={$this->_database}";
     }
     $force = $force === true ? PGSQL_CONNECT_FORCE_NEW : 0;
     if ($this->_persistent == true) {
         $this->_connection = pg_pconnect($constr, $force);
     } else {
         $this->_connection = pg_connect($constr, $force);
     }
     if ($this->_connection === false) {
         return false;
     }
     if (@pg_query($this->_connection, 'ROLLBACK') === false) {
         return false;
     }
     if (function_exists('pg_set_error_verbosity')) {
         pg_set_error_verbosity($this->_connection, PGSQL_ERRORS_VERBOSE);
     }
     // "If libpq is compiled without multibyte encoding support, pg_client_encoding() always returns SQL_ASCII."
     if (pg_set_client_encoding($this->_connection, 'UNICODE') == -1) {
         return false;
     }
     $this->_log['encoding'] = pg_client_encoding($this->_connection);
     return true;
 }
开发者ID:TinoDidriksen,项目名称:pjj-chats,代码行数:52,代码来源:postgresql.php

示例13: pg_client_encoding

 // If schema is defined and database supports schemas, then set the
 // schema explicitly.
 if (isset($_REQUEST['database']) && isset($_REQUEST['schema'])) {
     $status = $data->setSchema($_REQUEST['schema']);
     if ($status != 0) {
         echo $lang['strbadschema'];
         exit;
     }
 }
 // Get database encoding
 $dbEncoding = $data->getDatabaseEncoding();
 // Set client encoding to database encoding
 if ($dbEncoding != '') {
     // Explicitly change client encoding if it's different to server encoding.
     if (function_exists('pg_client_encoding')) {
         $currEncoding = pg_client_encoding($data->conn->_connectionID);
     } elseif (function_exists('pg_clientencoding')) {
         $currEncoding = pg_clientencoding($data->conn->_connectionID);
     } else {
         $currEncoding = null;
     }
     if ($currEncoding != $dbEncoding) {
         $status = $data->setClientEncoding($dbEncoding);
         if ($status != 0 && $status != -99) {
             echo $lang['strbadencoding'];
             exit;
         }
     }
     // Override $lang['appcharset']
     if (isset($data->codemap[$dbEncoding])) {
         $lang['appcharset'] = $data->codemap[$dbEncoding];
开发者ID:hardikk,项目名称:HNH,代码行数:31,代码来源:lib.inc.php

示例14: pg_connect

<?php

// optional functions
include 'config.inc';
$db = pg_connect($conn_str);
$enc = pg_client_encoding($db);
pg_set_client_encoding($db, $enc);
if (function_exists('pg_set_error_verbosity')) {
    pg_set_error_verbosity(PGSQL_ERRORS_TERSE);
    pg_set_error_verbosity(PGSQL_ERRORS_DEFAULT);
    pg_set_error_verbosity(PGSQL_ERRORS_VERBOSE);
}
echo "OK";
开发者ID:badlamer,项目名称:hhvm,代码行数:13,代码来源:07optional.php

示例15: ClientEncoding

 public function ClientEncoding($enc)
 {
     return is_null($enc) ? pg_client_encoding($this->connection) : pg_set_client_encoding($this->connection, $enc);
 }
开发者ID:raj47i,项目名称:PHP.Fx,代码行数:4,代码来源:pgsqli.php


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