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


PHP pg_set_client_encoding函数代码示例

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


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

示例1: connect

 /**
  * 连接数据库方法
  * @access public
  */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         $pconnect = !empty($config['params']['persist']) ? $config['params']['persist'] : $this->pconnect;
         $conn = $pconnect ? 'pg_pconnect' : 'pg_connect';
         $this->linkID[$linkNum] = $conn('host=' . $config['hostname'] . ' port=' . $config['hostport'] . ' dbname=' . $config['database'] . ' user=' . $config['username'] . '  password=' . $config['password']);
         if (0 !== pg_connection_status($this->linkID[$linkNum])) {
             E($this->error(false));
         }
         //设置编码
         pg_set_client_encoding($this->linkID[$linkNum], $config['charset']);
         //$pgInfo = pg_version($this->linkID[$linkNum]);
         //$dbVersion = $pgInfo['server'];
         // 标记连接成功
         $this->connected = true;
         //注销数据库安全信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
开发者ID:2flying2,项目名称:IDF-CTF-PLAT,代码行数:29,代码来源:Pgsql.class.php

示例2: connect

 /**
  * Connect to database
  *
  * @param array $options
  * @return array
  */
 public function connect($options)
 {
     $result = ['version' => null, 'status' => 0, 'error' => [], 'errno' => 0, 'success' => false];
     // we could pass an array or connection string right a way
     if (is_array($options)) {
         $str = 'host=' . $options['host'] . ' port=' . $options['port'] . ' dbname=' . $options['dbname'] . ' user=' . $options['username'] . ' password=' . $options['password'];
     } else {
         $str = $options;
     }
     $connection = pg_connect($str);
     if ($connection !== false) {
         $this->db_resource = $connection;
         $this->connect_options = $options;
         $this->commit_status = 0;
         pg_set_error_verbosity($connection, PGSQL_ERRORS_VERBOSE);
         pg_set_client_encoding($connection, 'UNICODE');
         $result['version'] = pg_version($connection);
         $result['status'] = pg_connection_status($connection) === PGSQL_CONNECTION_OK ? 1 : 0;
         $result['success'] = true;
     } else {
         $result['error'][] = 'db::connect() : Could not connect to database server!';
         $result['errno'] = 1;
     }
     return $result;
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:31,代码来源:base.php

示例3: establishConnection

 /**
  * Establish a new connection to postgreSQL server.
  *
  * @return string | boolean postgreSQL persistent link identifier on success, or FALSE on failure.
  */
 private function establishConnection()
 {
     $function = $this->config['persistent'] ? 'pg_pconnect' : 'pg_connect';
     $connection = $function('host=' . $this->config['host'] . ' port=' . $this->config['port'] . ' dbname=' . $this->config['database'] . ' user=' . $this->config['user'] . ' password=' . $this->config['password'], false);
     pg_set_client_encoding($connection, $this->config['charset']);
     return $connection;
 }
开发者ID:finzaiko,项目名称:Panada,代码行数:12,代码来源:Pgsql.php

示例4: connect

 function connect()
 {
     global $php_errormsg;
     $persistent = isset($this->config['persistent']) ? $this->config['persistent'] : null;
     $connstr = '';
     if ($host = $this->config['host']) {
         $connstr = 'host=' . $host;
     }
     if ($port = $this->config['port']) {
         $connstr .= ' port=' . $port;
     }
     if ($database = $this->config['database']) {
         $connstr .= ' dbname=\'' . addslashes($database) . '\'';
     }
     if ($user = $this->config['user']) {
         $connstr .= ' user=\'' . addslashes($user) . '\'';
     }
     if ($password = $this->config['password']) {
         $connstr .= ' password=\'' . addslashes($password) . '\'';
     }
     if ($persistent) {
         $conn = @pg_pconnect($connstr);
     } else {
         $conn = @pg_connect($connstr);
     }
     if (!is_resource($conn)) {
         $this->_raiseError($php_errormsg);
     }
     if (isset($this->config['charset']) && ($charset = $this->config['charset'])) {
         pg_set_client_encoding($conn, $charset);
     }
     $this->connectionId = $conn;
 }
开发者ID:snowjobgit,项目名称:limb,代码行数:33,代码来源:lmbPgsqlConnection.class.php

示例5: connect

 public function connect($config = [])
 {
     $this->config = $config;
     $dsn = 'host=' . $this->config['host'] . ' ';
     if (!empty($this->config['port'])) {
         $dsn .= 'port=' . $this->config['port'] . ' ';
     }
     if (!empty($this->config['database'])) {
         $dsn .= 'dbname=' . $this->config['database'] . ' ';
     }
     if (!empty($this->config['user'])) {
         $dsn .= 'user=' . $this->config['user'] . ' ';
     }
     if (!empty($this->config['password'])) {
         $dsn .= 'password=' . $this->config['password'] . ' ';
     }
     if (!empty($this->config['dsn'])) {
         $dsn = $this->config['dsn'];
     }
     $dsn = rtrim($dsn);
     $this->connect = $this->config['pconnect'] === true ? @pg_pconnect($dsn) : @pg_connect($dsn);
     if (empty($this->connect)) {
         die(getErrorMessage('Database', 'connectError'));
     }
     if (!empty($this->config['charset'])) {
         pg_set_client_encoding($this->connect, $this->config['charset']);
     }
 }
开发者ID:znframework,项目名称:znframework,代码行数:28,代码来源:Postgres.php

示例6: set_client_encoding

 /**
  * Set client encoding
  * @param string $encoding
  * @return int 0 on success or -1 on error
  */
 function set_client_encoding($encoding = "")
 {
     if ($encoding != "") {
         return pg_set_client_encoding($this->connection, $encoding);
     }
     return 0;
 }
开发者ID:zenga22,项目名称:knowledgeroot1,代码行数:12,代码来源:class-pgsql.php

示例7: init

 function init()
 {
     $this->query("set client_encoding = 'UTF-8'");
     pg_set_client_encoding("UNICODE");
     $this->query("set datestyle = 'ISO, european'");
     $this->query("set TIME ZONE 0");
     return true;
 }
开发者ID:cs-team,项目名称:tiny_tiny_rss-openshift-quickstart,代码行数:8,代码来源:pgsql.php

示例8: connect_db

function connect_db()
{
    if ($conn = pg_connect("host=" . SQL_HOST . " port=" . SQL_PORT . " dbname=" . SQL_DATABASE . " user=" . SQL_USERNAME . " password=" . SQL_PASSWORD)) {
        pg_set_client_encoding($conn, 'UNICODE');
        return $conn;
    } else {
        return false;
    }
}
开发者ID:BackupTheBerlios,项目名称:diarusie-svn,代码行数:9,代码来源:functions.inc.php

示例9: WikiDB_backend_PearDB

 function WikiDB_backend_PearDB($dbparams)
 {
     // Find and include PEAR's DB.php. maybe we should force our private version again...
     // if DB would have exported its version number, it would be easier.
     @(require_once 'DB/common.php');
     // Either our local pear copy or the system one
     // check the version!
     $name = check_php_version(5) ? "escapeSimple" : strtolower("escapeSimple");
     // TODO: apparently some Pear::Db version adds LIMIT 1,0 to getOne(),
     // which is invalid for "select version()"
     if (!in_array($name, get_class_methods("DB_common"))) {
         $finder = new FileFinder();
         $dir = dirname(__FILE__) . "/../../pear";
         $finder->_prepend_to_include_path($dir);
         include_once "{$dir}/DB/common.php";
         // use our version instead.
         if (!in_array($name, get_class_methods("DB_common"))) {
             $pearFinder = new PearFileFinder("lib/pear");
             $pearFinder->includeOnce('DB.php');
         } else {
             include_once "{$dir}/DB.php";
         }
     } else {
         include_once "DB.php";
     }
     // Install filter to handle bogus error notices from buggy DB.php's.
     // TODO: check the Pear_DB version, but how?
     if (0) {
         global $ErrorManager;
         $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_pear_notice_filter'));
         $this->_pearerrhandler = true;
     }
     // Open connection to database
     $this->_dsn = $dbparams['dsn'];
     $this->_dbparams = $dbparams;
     $this->_lock_count = 0;
     // persistent is usually a DSN option: we override it with a config value.
     //   phptype://username:password@hostspec/database?persistent=false
     $dboptions = array('persistent' => DATABASE_PERSISTENT, 'debug' => 2);
     //if (preg_match('/^pgsql/', $this->_dsn)) $dboptions['persistent'] = false;
     $this->_dbh = DB::connect($this->_dsn, $dboptions);
     $dbh =& $this->_dbh;
     if (DB::isError($dbh)) {
         trigger_error(sprintf("Can't connect to database: %s", $this->_pear_error_message($dbh)), E_USER_ERROR);
     }
     $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, array($this, '_pear_error_callback'));
     $dbh->setFetchMode(DB_FETCHMODE_ASSOC);
     $prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : '';
     $this->_table_names = array('page_tbl' => $prefix . 'page', 'version_tbl' => $prefix . 'version', 'link_tbl' => $prefix . 'link', 'recent_tbl' => $prefix . 'recent', 'nonempty_tbl' => $prefix . 'nonempty');
     $page_tbl = $this->_table_names['page_tbl'];
     $version_tbl = $this->_table_names['version_tbl'];
     $p = strlen(PAGE_PREFIX) + 1;
     $this->page_tbl_fields = "{$page_tbl}.id AS id, substring({$page_tbl}.pagename from {$p}) AS pagename, {$page_tbl}.hits AS hits";
     $this->version_tbl_fields = "{$version_tbl}.version AS version, {$version_tbl}.mtime AS mtime, " . "{$version_tbl}.minor_edit AS minor_edit, {$version_tbl}.content AS content, {$version_tbl}.versiondata AS versiondata";
     $this->_expressions = array('maxmajor' => "MAX(CASE WHEN minor_edit=0 THEN version END)", 'maxminor' => "MAX(CASE WHEN minor_edit<>0 THEN version END)", 'maxversion' => "MAX(version)", 'notempty' => "<>''", 'iscontent' => "content<>''");
     pg_set_client_encoding("iso-8859-1");
 }
开发者ID:neymanna,项目名称:fusionforge,代码行数:57,代码来源:PearDB.php

示例10: WikiDB_backend_PearDB_ffpgsql

 function WikiDB_backend_PearDB_ffpgsql($dbparams)
 {
     $dbparams['dsn'] = str_replace('ffpgsql:', 'pgsql:', $dbparams['dsn']);
     parent::WikiDB_backend_PearDB_pgsql($dbparams);
     $p = strlen(PAGE_PREFIX) + 1;
     $page_tbl = $this->_table_names['page_tbl'];
     $this->page_tbl_fields = "{$page_tbl}.id AS id, substring({$page_tbl}.pagename from {$p}) AS pagename, {$page_tbl}.hits AS hits";
     pg_set_client_encoding("iso-8859-1");
 }
开发者ID:hugcoday,项目名称:wiki,代码行数:9,代码来源:PearDB_ffpgsql.php

示例11: deleteLocal

function deleteLocal()
{
    include '../conf/config.php';
    // connection to database goes here
    $dbconn = pg_connect("host={$host} port={$port} dbname={$db_name} user={$username} password={$password}") or die('Could not connect: ' . pg_last_error());
    pg_set_client_encoding($dbconn, "utf-8");
    $actualiza = "DELETE FROM locais  WHERE id = " . $_POST["idlocal"] . ";  ";
    pg_query($actualiza) or die('Could not insert: ' . pg_last_error());
    pg_close($dbconn);
}
开发者ID:geoabstract,项目名称:scq_comercio,代码行数:10,代码来源:deleteSheet.php

示例12: connect

 public function connect()
 {
     $this->conn = pg_connect($this->connString);
     if ($this->conn === FALSE) {
         throw new DBException("Failed to connect to {$this->connString}");
     }
     if (pg_set_client_encoding($this->conn, "UTF-8") != 0) {
         throw new DBException("Failed to set UTF-8 client encoding: " . pg_last_error($this->conn));
     }
 }
开发者ID:kotishe,项目名称:API-for-AOServer,代码行数:10,代码来源:AccountListLoader.inc.php

示例13: setClientCharset

 /**
  * A method to set the client charset
  *
  * @param string $charset
  * @return mixed True on success, PEAR_Error otherwise
  */
 function setClientCharset($charset)
 {
     if (!empty($charset) && $this->oDbh) {
         $pg = $this->oDbh->getConnection();
         if (@pg_set_client_encoding($pg, $charset) == -1) {
             return new PEAR_Error(pg_errormessage($pg));
         }
     }
     return true;
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:16,代码来源:pgsql.php

示例14: updateLocal

function updateLocal()
{
    include '../conf/config.php';
    // connection to database goes here
    $dbconn = pg_connect("host={$host} port={$port} dbname={$db_name} user={$username} password={$password}") or die('Could not connect: ' . pg_last_error());
    pg_set_client_encoding($dbconn, "utf-8");
    $actualiza = "UPDATE locais SET \n\t\t\t\t\t\tnomecomercial='" . $_POST["nome"] . "', \n\t\t\t\t\t\tactividade_id='" . $_POST["actividade_id"] . "',\n\n\t\t\t\t\t\trexime='" . $_POST["rexime"] . "',\n\t\t\t\t\t\tapertura='" . $_POST["apertura"] . "',\n\t\t\t\t\t\tm2='" . $_POST["superficie"] . "',\n\t\t\t\t\t\tnomexerente='" . $_POST["xerente"] . "',\n\n\t\t\t\t\t\tzone_id='" . $_POST["zone_id"] . "',\n\t\t\t\t\t\t\n\t\t\t\t\t\tvia_id='" . $_POST["viaId"] . "',\n\t\t\t\t\t\trua='" . $_POST["rua"] . "',\n\t\t\t\t\t\tnum='" . $_POST["num"] . "',\n\t\t\t\t\t\tcp='" . $_POST["cp"] . "',\n\t\t\t\t\t\tlat='" . $_POST["lat"] . "',\n\t\t\t\t\t\tlon='" . $_POST["lon"] . "',\n\n\t\t\t\t\t\tweb='" . $_POST["web"] . "',\n\t\t\t\t\t\trs_facebook='" . $_POST["rs_facebook"] . "',\n\t\t\t\t\t\trs_twitter='" . $_POST["rs_twitter"] . "',\n\t\t\t\t\t\trs_pinterest='" . $_POST["rs_pinterest"] . "',\n\t\t\t\t\t\trs_youtube='" . $_POST["rs_youtube"] . "',\n\t\t\t\t\t\trs_instagram='" . $_POST["rs_instagram"] . "',\n\n\t\t\t\t\t\temail='" . $_POST["email"] . "',\n\t\t\t\t\t\ttelefono='" . $_POST["tlf"] . "',\n\t\t\t\t\t\tmobil='" . $_POST["mobil"] . "',\n\t\t\t\t\t\tfax='" . $_POST["fax"] . "'\n\t\t\t\t\t\t\n\n\t\t\t\t\tWHERE id = " . $_POST["idlocal"] . ";  ";
    pg_query($actualiza) or die('Could not insert: ' . pg_last_error());
    pg_close($dbconn);
}
开发者ID:geoabstract,项目名称:scq_comercio,代码行数:10,代码来源:updateSheet.php

示例15: pgBackupRestore

 function pgBackupRestore($uiHost, $uiUser, $uiPassword, $uiDatabase, $uiPort = 5432)
 {
     $this->Link_ID = pg_pconnect("host={$uiHost} port={$uiPort} dbname={$uiDatabase} user={$uiUser} password={$uiPassword}");
     if (!$this->Link_ID) {
         $this->Error("Can't connect to the Postgres Database", true);
     }
     $this->Database = $uiDatabase;
     $this->Connected = $this->Link_ID ? true : false;
     pg_set_client_encoding($this->Link_ID, $this->Encoding);
 }
开发者ID:SysBind,项目名称:opensis-ml,代码行数:10,代码来源:pgBackupRestore.class.php


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