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


PHP pg_parameter_status函数代码示例

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


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

示例1: 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

示例2: connect

 public function connect()
 {
     if ($this->_connection) {
         return;
     }
     try {
         $this->_connection = empty($this->_config['connection']['persistent']) ? pg_connect($this->_config['connection']['info'], PGSQL_CONNECT_FORCE_NEW) : pg_pconnect($this->_config['connection']['info'], PGSQL_CONNECT_FORCE_NEW);
     } catch (ErrorException $e) {
         throw new Database_Exception(':error', array(':error' => $e->getMessage()));
     }
     if (!is_resource($this->_connection)) {
         throw new Database_Exception('Unable to connect to PostgreSQL ":name"', array(':name' => $this->_instance));
     }
     $this->_version = pg_parameter_status($this->_connection, 'server_version');
     if (!empty($this->_config['charset'])) {
         $this->set_charset($this->_config['charset']);
     }
     if (empty($this->_config['schema'])) {
         // Assume the default schema without changing the search path
         $this->_config['schema'] = 'public';
     } else {
         if (!pg_send_query($this->_connection, 'SET search_path = ' . $this->_config['schema'] . ', pg_catalog')) {
             throw new Database_Exception(pg_last_error($this->_connection));
         }
         if (!($result = pg_get_result($this->_connection))) {
             throw new Database_Exception(pg_last_error($this->_connection));
         }
         if (pg_result_status($result) !== PGSQL_COMMAND_OK) {
             throw new Database_Exception(pg_result_error($result));
         }
     }
 }
开发者ID:alekseyshavrak,项目名称:3cx,代码行数:32,代码来源:PostgreSQL.php

示例3: sql_connect

 /**
  * Connect to server
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
 {
     $connect_string = '';
     if ($sqluser) {
         $connect_string .= "user={$sqluser} ";
     }
     if ($sqlpassword) {
         $connect_string .= "password={$sqlpassword} ";
     }
     if ($sqlserver) {
         if (strpos($sqlserver, ':') !== false) {
             list($sqlserver, $port) = explode(':', $sqlserver);
         }
         if ($sqlserver !== 'localhost') {
             $connect_string .= "host={$sqlserver} ";
         }
         if ($port) {
             $connect_string .= "port={$port} ";
         }
     }
     $schema = '';
     if ($database) {
         $this->dbname = $database;
         if (strpos($database, '.') !== false) {
             list($database, $schema) = explode('.', $database);
         }
         $connect_string .= "dbname={$database}";
     }
     $this->persistency = $persistency;
     $this->db_connect_id = $this->persistency ? @pg_pconnect($connect_string, $new_link) : @pg_connect($connect_string, $new_link);
     if ($this->db_connect_id) {
         // determine what version of PostgreSQL is running, we can be more efficient if they are running 8.2+
         if (version_compare(PHP_VERSION, '5.0.0', '>=')) {
             $this->pgsql_version = @pg_parameter_status($this->db_connect_id, 'server_version');
         } else {
             $query_id = @pg_query($this->db_connect_id, 'SELECT VERSION()');
             $row = @pg_fetch_assoc($query_id, null);
             @pg_free_result($query_id);
             if (!empty($row['version'])) {
                 $this->pgsql_version = substr($row['version'], 10);
             }
         }
         if (!empty($this->pgsql_version) && $this->pgsql_version[0] >= '8' && $this->pgsql_version[2] >= '2') {
             $this->multi_insert = true;
         }
         if ($schema !== '') {
             @pg_query($this->db_connect_id, 'SET search_path TO ' . $schema);
         }
         return $this->db_connect_id;
     }
     return $this->sql_error('');
 }
开发者ID:jambik,项目名称:elenaburgon,代码行数:55,代码来源:postgres.php

示例4: get_versions

 public function get_versions()
 {
     $version['engine'] = 'PostgreSQL';
     $version['client'] = 'N/A';
     $version['server'] = 'N/A';
     $version = array_merge($version, pg_version($this->_owner->connect_id));
     if ($version['server'] == 'N/A') {
         //pgsql not compiled into php
         $version['server'] = pg_parameter_status('server_version');
         //pgsql 7.4+
     }
     return $version;
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:13,代码来源:postgresql.php

示例5: get_versions

 function get_versions()
 {
     $version['engine'] = 'PostgreSQL';
     $version['client'] = 'N/A';
     $version['server'] = 'N/A';
     if (function_exists('pg_version')) {
         //php5+
         $version = array_merge($version, pg_version($this->_owner->connect_id));
         if ($version['server'] == 'N/A') {
             //pgsql not compiled into php
             $version['server'] = pg_parameter_status('server_version');
             //pgsql 7.4+
         }
     } else {
         if ($result = pg_query($this->_owner->connect_id, 'SELECT VERSION()')) {
             list($v) = pg_fetch_row($result);
             pg_free_result($result);
             if (!empty($v)) {
                 $version['server'] = preg_replace('#PostgreSQL ([0-9\\.]+).*#i', '\\1', $v);
             }
         }
     }
     return $version;
 }
开发者ID:cbsistem,项目名称:nexos,代码行数:24,代码来源:postgresql_mngr.php

示例6: isSuperUser

 /**
  * Determines whether or not a user is a super user
  * @param $username The username of the user
  * @return True if is a super user, false otherwise
  */
 function isSuperUser($username = '')
 {
     $this->clean($username);
     if (empty($usename)) {
         $val = pg_parameter_status($this->conn->_connectionID, 'is_superuser');
         if ($val !== false) {
             return $val == 'on';
         }
     }
     $sql = "SELECT usesuper FROM pg_user WHERE usename='{$username}'";
     $usesuper = $this->selectField($sql, 'usesuper');
     if ($usesuper == -1) {
         return false;
     } else {
         return $usesuper == 't';
     }
 }
开发者ID:phppgadmin,项目名称:phppgadmin,代码行数:22,代码来源:Postgres.php

示例7: getAttribute

 /**
  * Public method:
  *	Quotes correctly a string for this database
  *       	this->getAttribute( $attribute:Integer ):Mixed
  * @Param	Integer		a constant [	PDO_ATTR_SERVER_INFO,
  * 						PDO_ATTR_SERVER_VERSION,
  *                                              PDO_ATTR_CLIENT_VERSION,
  *                                              PDO_ATTR_PERSISTENT	]
  * @Return	Mixed		correct information or false
  */
 function getAttribute($attribute)
 {
     $result = false;
     switch ($attribute) {
         case PDO_ATTR_SERVER_INFO:
             $result = pg_parameter_status($this->__connection, 'server_encoding');
             break;
         case PDO_ATTR_SERVER_VERSION:
             $result = pg_parameter_status($this->__connection, 'server_version');
             break;
         case PDO_ATTR_CLIENT_VERSION:
             $result = pg_parameter_status($this->__connection, 'server_version');
             $result .= ' ' . pg_parameter_status($this->__connection, 'client_encoding');
             break;
         case PDO_ATTR_PERSISTENT:
             $result = $this->__persistent;
             break;
     }
     return $result;
 }
开发者ID:D4rk4,项目名称:Kusaba-z,代码行数:30,代码来源:PDOStatement_pgsql.class.php

示例8: testRangeTypeConverterFromMetadata

 public function testRangeTypeConverterFromMetadata()
 {
     if (!TESTS_SAD_SPIRIT_PG_WRAPPER_CONNECTION_STRING) {
         $this->markTestSkipped('Connection string is not configured');
     }
     $connection = new Connection(TESTS_SAD_SPIRIT_PG_WRAPPER_CONNECTION_STRING, false);
     if (version_compare(pg_parameter_status($connection->getResource(), 'server_version'), '9.2.0', '<')) {
         $this->markTestSkipped('Connection to PostgreSQL 9.2+ required');
     }
     $connection->setTypeConverterFactory($this->factory);
     $connection->execute("drop type if exists textrange");
     $connection->execute("create type textrange as range (subtype=text, collation=\"C\")");
     $this->assertEquals(new RangeConverter(new StringConverter()), $this->factory->getConverter('textrange'));
 }
开发者ID:sad-spirit,项目名称:pg-wrapper,代码行数:14,代码来源:TypeConverterFactoryTest.php

示例9: check_postgres_version

 /**
  * check postgres serversion. at least 8.2 required
  *
  * @return mixed bool true if successful, false if unknown version, else server_version
  */
 public function check_postgres_version()
 {
     $server_version = pg_parameter_status($this->dbconn, "server_version");
     if (false !== $server_version) {
         if (-1 == version_compare($server_version, "8.2")) {
             return $server_version;
         }
         // version ok
         return true;
     }
     // unknown server_version
     return false;
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:18,代码来源:setupdb.php

示例10: 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

示例11: _loadTypes

    /**
     * Populates the types list from pg_catalog.pg_type table
     *
     * @param bool $force Force loading from database even if cached list is available
     * @throws exceptions\InvalidQueryException
     */
    private function _loadTypes($force = false)
    {
        $cacheKey = $this->_connection->getConnectionId() . '-types';
        if (!($cache = $this->_connection->getMetadataCache()) || $force || null === ($this->_dbTypes = $cache->getItem($cacheKey))) {
            $this->_dbTypes = array('composite' => array(), 'array' => array(), 'range' => array(), 'names' => array());
            $sql = <<<SQL
    select t.oid, nspname, typname, typarray, typrelid
    from pg_catalog.pg_type as t, pg_catalog.pg_namespace as s
    where t.typnamespace = s.oid and
          typtype != 'd'
    order by 4 desc
SQL;
            if (!($res = @pg_query($this->_connection->getResource(), $sql))) {
                throw new exceptions\InvalidQueryException(pg_last_error($this->_connection->getResource()));
            }
            while ($row = pg_fetch_assoc($res)) {
                if (!isset($this->_dbTypes['names'][$row['typname']])) {
                    $this->_dbTypes['names'][$row['typname']] = array($row['nspname'] => $row['oid']);
                } else {
                    $this->_dbTypes['names'][$row['typname']][$row['nspname']] = $row['oid'];
                }
                if ('0' !== $row['typarray']) {
                    $this->_dbTypes['array'][$row['typarray']] = $row['oid'];
                }
                if ('0' !== $row['typrelid']) {
                    $this->_dbTypes['composite'][$row['oid']] = $row['typrelid'];
                }
            }
            pg_free_result($res);
            if (version_compare(pg_parameter_status($this->_connection->getResource(), 'server_version'), '9.2.0', '>=')) {
                if (!($res = @pg_query($this->_connection->getResource(), "select rngtypid, rngsubtype from pg_range"))) {
                    throw new exceptions\InvalidQueryException(pg_last_error($this->_connection->getResource()));
                }
                while ($row = pg_fetch_assoc($res)) {
                    $this->_dbTypes['range'][$row['rngtypid']] = $row['rngsubtype'];
                }
            }
            if ($cache) {
                $cache->setItem($cacheKey, $this->_dbTypes);
            }
        }
        $this->_oidMap = array();
        foreach ($this->_dbTypes['names'] as $typeName => $schemas) {
            foreach ($schemas as $schemaName => $oid) {
                $this->_oidMap[$oid] = array($schemaName, $typeName);
            }
        }
    }
开发者ID:sad-spirit,项目名称:pg-wrapper,代码行数:54,代码来源:TypeConverterFactory.php

示例12: inputNotNull

 protected function inputNotNull($native)
 {
     foreach ($this->getFormats($this->_style) as $format) {
         if ($value = \DateTime::createFromFormat('!' . $format, $native)) {
             return $value;
         }
     }
     // check whether datestyle setting changed
     if ($this->_connection && $this->_style !== ($style = pg_parameter_status($this->_connection, 'DateStyle'))) {
         $this->_style = $style;
         foreach ($this->getFormats($this->_style) as $format) {
             if ($value = \DateTime::createFromFormat('!' . $format, $native)) {
                 return $value;
             }
         }
     }
     throw TypeConversionException::unexpectedValue($this, 'input', $this->expectation, $native);
 }
开发者ID:sad-spirit,项目名称:pg-wrapper,代码行数:18,代码来源:BaseDateTimeConverter.php

示例13: setConnectionResource

 public function setConnectionResource($resource)
 {
     $this->_connection = $resource;
     // if connection was made to PostgreSQL 9.0+, then use 'hex' encoding
     $this->useHexEncoding(version_compare(pg_parameter_status($resource, 'server_version'), '9.0.0', '>='));
 }
开发者ID:sad-spirit,项目名称:pg-wrapper,代码行数:6,代码来源:ByteaConverter.php

示例14: getVersion

 public function getVersion()
 {
     return @pg_parameter_status($this->_hMaster, 'server_version');
 }
开发者ID:googlesky,项目名称:snsp.vn,代码行数:4,代码来源:postgres.class.php

示例15: db_version

 public function db_version($handle)
 {
     if (is_resource($handle)) {
         return pg_parameter_status($handle, 'server_version');
     }
     return null;
 }
开发者ID:archcidburnziso,项目名称:Bilboplanet,代码行数:7,代码来源:class.pgsql.php


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