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


PHP pg_version函数代码示例

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


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

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

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

示例3: lastInsertId

 public function lastInsertId()
 {
     $_temp = $this->lastHash;
     $lastResult = $this->results[$this->lastHash];
     $this->executeQuery("SELECT version() AS ver");
     $row = $this->getRow();
     $ver = pg_version($this->connection);
     $v = $ver['server'];
     $table = func_num_args() > 0 ? func_get_arg(0) : null;
     $column = func_num_args() > 1 ? func_get_arg(1) : null;
     if ($table == null && $v == '8.1') {
         $sql = "SELECT LASTVAL() AS ins_id";
     } elseif ($table != null && $column != null && $v >= '8.0') {
         $sql = sprintf("SELECT pg_get_serial_sequence('%s','%s') as seq", $table, $column);
         $this->execte($sql);
         $row = $this->getRow();
         $sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row['seq']);
     } elseif ($table != null) {
         // seq_name passed in table parameter
         $sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table);
     } else {
         return pg_last_oid($lastResult);
     }
     $this->execute($sql);
     $row = $this->getRow();
     $this->lasthash = $_temp;
     return $row['ins_id'];
 }
开发者ID:prajeenapk,项目名称:VioletPHP,代码行数:28,代码来源:postgresqlDriver.php

示例4: navi

function navi()
{
    global $SIDU;
    $conn = $SIDU['conn'][$SIDU[0]];
    $link = @explode(',', $_GET['id']);
    $eng = @array('my' => 'MySQL', 'pg' => 'Postgres', 'sl' => 'SQLite');
    @sidu_sort($SIDU[5], $SIDU[6], $SIDU[7], $SIDU['page']['sortObj']);
    $obj = @array("r" => @lang(1416), "v" => @lang(1417), "S" => @lang(1418), "f" => @lang(1419));
    if ($link[3] != '') {
        if ($link[3] == 'r') {
            echo "<a href='tab-new.php?id={$SIDU['0']},{$SIDU['1']},{$SIDU['2']},{$SIDU['3']},{$SIDU['4']},{$SIDU['5']},{$SIDU['6']}' onclick=\"xwin(this.href,700,500);return false\" ", @html_hkey("=", @lang(1401)), ">", @html_img('img/tool-add'), "</a>{$SIDU['sep']}";
        }
        if ($link[3] == 'r' || $link[3] == 'v') {
            echo "<a href='#' ", @html_hkey("E", @lang(1402)), " onclick='dbexp(\"{$SIDU['0']},{$SIDU['1']},{$SIDU['2']},{$SIDU['3']}\",\"objs[]\")'>", @html_img('img/tool-down'), $SIDU['page']['menuText'] ? @lang(1403) : "", "</a>";
        }
        if ($link[3] == 'r') {
            echo " <a href='imp.php?id={$SIDU['0']},{$SIDU['1']},{$SIDU['2']}' ", @html_hkey("I", @lang(1404)), " onclick='xwin(this.href);return false'>", @html_img('img/tool-imp'), $SIDU['page']['menuText'] ? @lang(1405) : "", "</a>";
        }
        if ($link[3] == 'r') {
            echo " <a href='#' onclick=\"showHide('objTool')\" title='", @lang(1406), "'>", @html_img('img/tool-sys'), $SIDU['page']['menuText'] ? @lang(1407) : "", "</a>\n\t\t\t<a href='#' onclick=\"setv('objcmd','Empty');return (confirm('", @lang(1409), "') ? dataTab.submit() : false)\" ", @html_hkey("-", @lang(1410)), ">", @html_img('img/tool-flush'), $SIDU['page']['menuText'] ? @lang(1408) : "", "</a>";
        }
        echo " <a href='#' onclick=\"setv('objcmd','Drop'); return (confirm('", @lang(1412, $obj[$SIDU[3]]), "') ? dataTab.submit() : false)\" ", @html_hkey("X", @lang(1413)), ">", @html_img('img/tool-x'), $SIDU['page']['menuText'] ? @lang(1411) : "", "</a>\n\t\t\t<a href='" . ($conn[1] == "sl" ? "tab.php?id={$SIDU['0']},{$SIDU['1']},0,r,sqlite_master'" : "#' onclick=\"showHide('DBseek')\"") . " ", @html_hkey("F", @lang(1414)), ">", @html_img('img/tool-find'), $SIDU['page']['menuText'] ? @lang(1415) : "", "</a>{$SIDU['sep']}", @html_img("img/x{$link['3']}"), " <a href='db.php?id={$link['0']},{$link['1']},,,,{$SIDU['5']},{$SIDU['6']}'>{$link['1']}</a>", $link[2] ? " » <a href='db.php?id={$link['0']},{$link['1']},{$link['2']},{$link['3']},,{$SIDU['5']},{$SIDU['6']}'>{$link['2']}</a>" : "", $link[4] != '' ? " » {$link['4']}" : "";
    } else {
        if ($conn[1] == "my") {
            $serv['server'] = @mysql_get_server_info();
        } elseif ($conn[1] == "pg") {
            $serv = @pg_version();
        } else {
            $serv['server'] = @sqlite_libversion();
        }
        echo @html_img("img/eng-{$conn['1']}"), " <b>SIDU 3.0</b> for <b>{$eng[$conn[1]]}</b>\n\t\t{$SIDU['sep']}<a href='" . ($conn[1] == "sl" ? "tab.php?id={$SIDU['0']},{$SIDU['1']},0,r,sqlite_master'" : "#' onclick=\"showHide('DBseek')\"") . " ", @html_hkey("F", @lang(1414)), @html_img('img/tool-find'), "</a>\n\t\t<a href='db.php?id={$link['0']},,,,,{$SIDU['5']},{$SIDU['6']}'><b>", $conn[1] == "sl" ? "SQLite" : "{$conn['3']}@{$conn['2']}", "</b></a> v {$serv['server']}\n\t\t{$SIDU['sep']} ", @date("Y-m-d H:i:s");
    }
}
开发者ID:abdeljawwad,项目名称:sedr,代码行数:33,代码来源:db.php

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

示例6: getDriver

 /**
  * Gets the name of the correct database driver to use.  As a side effect,
  * sets the platform.
  * @param (return-by-ref) $description A description of the database and version
  * @return The class name of the driver eg. Postgres84
  * @return null if version is < 7.4
  * @return -3 Database-specific failure
  */
 function getDriver(&$description)
 {
     // If we're on a recent enough PHP 5, and against PostgreSQL 7.4 or
     // higher, we don't need to query for the version.  This gives a great
     // speed up.
     if (function_exists('pg_version')) {
         $v = pg_version($this->conn->_connectionID);
         if (isset($v['server'])) {
             $version = $v['server'];
         }
     }
     // If we didn't manage to get the version without a query, query...
     if (!isset($version)) {
         $adodb = new ADODB_base($this->conn);
         $sql = "SELECT VERSION() AS version";
         $field = $adodb->selectField($sql, 'version');
         // Check the platform, if it's mingw, set it
         if (preg_match('/ mingw /i', $field)) {
             $this->platform = 'MINGW';
         }
         $params = explode(' ', $field);
         if (!isset($params[1])) {
             return -3;
         }
         $version = $params[1];
         // eg. 8.4.4
     }
     $description = "PostgreSQL {$version}";
     // Detect version and choose appropriate database driver
     switch (substr($version, 0, 3)) {
         case '8.4':
             return 'Postgres';
             break;
         case '8.3':
             return 'Postgres83';
             break;
         case '8.2':
             return 'Postgres82';
             break;
         case '8.1':
             return 'Postgres81';
             break;
         case '8.0':
         case '7.5':
             return 'Postgres80';
             break;
         case '7.4':
             return 'Postgres74';
             break;
     }
     /* All <7.4 versions are not supported */
     // if major version is 7 or less and wasn't catch in the
     // switch/case block, we have an unsupported version.
     if ((int) substr($version, 0, 1) < 8) {
         return null;
     }
     // If unknown version, then default to latest driver
     return 'Postgres';
 }
开发者ID:hardikk,项目名称:HNH,代码行数:67,代码来源:Connection.php

示例7: pgVersion

 public static function pgVersion()
 {
     // pg_version is only defined in postgres 7.4 and later
     if (function_exists('pg_version')) {
         return pg_version(self::connection());
     } else {
         // 7.4 is pretty old so older versions probably
         // won't support what we're looking for
         return 0;
     }
 }
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:11,代码来源:db_pgsql.php

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

示例9: version

 public static function version($mode = 'server')
 {
     if (array_key_exists('version', self::$dbProperties)) {
         return self::$dbProperties['version'];
     } else {
         self::$dbProperties['version'] = pg_version();
         if ($mode == 'server') {
             return self::$dbProperties['version']['server'];
         } else {
             return self::$dbProperties['version']['client'];
         }
     }
 }
开发者ID:webhacking,项目名称:Textcube,代码行数:13,代码来源:Adapter.php

示例10: getDatabaseVersion

 public function getDatabaseVersion($databaseConfig)
 {
     $conn = $this->createConnection($databaseConfig, $error);
     if (!$conn) {
         return false;
     } elseif ($conn instanceof PDO) {
         return $conn->getAttribute(PDO::ATTR_SERVER_VERSION);
     } elseif (is_resource($conn)) {
         $info = pg_version($conn);
         return $info['server'];
     } else {
         return false;
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-postgresql,代码行数:14,代码来源:PostgreSQLDatabaseConfigurationHelper.php

示例11: dbVersion

 /**
  * Database Engine detection
  * @return string the database versin
  */
 public static function dbVersion()
 {
     $profile = jDb::getProfile();
     //@TODO get the current dbLink to give it to each RDBMS function
     /*
             $tools = jDb::getTools();
             $version = $tools->dbVersion();*/
     if ($profile['driver'] == 'pgsql') {
         $version = pg_version();
     } elseif ($profile['driver'] == 'mysql') {
         $version = mysql_get_server_info();
     } elseif ($profile['driver'] == 'sqlite') {
         $version = sqlite_version();
     }
     return $profile['driver'] . ' ' . $version;
 }
开发者ID:havefnubb,项目名称:havefnubb,代码行数:20,代码来源:serverinfos.class.php

示例12: Open

 /**
  * 连接数据库
  * @param array $array 数据库连接配置
  *              $array=array(
  *                  'pgsql_server',
  *                  'pgsql_username',
  *                  'pgsql_password',
  *                  'pgsql_name',
  *                  'pgsql_pre',
  *                  'pgsql_port',
  *                  'persistent')
  *                  )
  * @return bool
  */
 public function Open($array)
 {
     $s = "host={$array[0]} port={$array[5]} dbname={$array[3]} user={$array[1]} password={$array[2]} options='--client_encoding=UTF8'";
     if (false == $array[5]) {
         $db_link = pg_connect($s);
     } else {
         $db_link = pg_pconnect($s);
     }
     if (!$db_link) {
         return false;
     } else {
         $this->dbpre = $array[4];
         $this->db = $db_link;
         $v = pg_version($db_link);
         $this->version = $v['client'];
         return true;
     }
 }
开发者ID:zblogcn,项目名称:zblogphp,代码行数:32,代码来源:dbpgsql.php

示例13: __construct

 /**
  * Db_Pgsql constructor.
  *
  * @param  array $args
  * @throws \Exception
  */
 public function __construct(array $args)
 {
     $this->args = $args;
     if (!is_callable('pgsql_connect')) {
         throw new \Exception(__METHOD__ . ': pgsql_connect is not supported.');
     }
     $this->conn = pg_connect(sprintf('host=%s user=%s password=%s dbname=%s', $args['host'], $args['user'], $args['pass'], $args['name']));
     if ($this->conn === false) {
         throw new \Exception(__METHOD__ . ': failed to connect to PostgreSQL server.');
     }
     $version = pg_version($this->conn);
     if (is_array($version) && isset($version['server'])) {
         $this->serverVersion = $this->getIntVersion($version['server']);
     } else {
         $this->serverVersion = 0;
     }
     if (!empty($args['charset'])) {
         pg_set_client_encoding($this->conn, $args['charset']);
     }
 }
开发者ID:mystralkk,项目名称:geeklog,代码行数:26,代码来源:pgsql.class.php

示例14: connect

 public function connect($dbIP, $dbUser, $dbPass, $dbName, $dbPort = null)
 {
     // check parameters
     if ($dbIP == '') {
         die('<b>ERROR:</b> no database host provided... <b>w2db.php, line ' . __LINE__ . '</b>');
     }
     if ($dbName == '') {
         die('<b>ERROR:</b> no database name provided... <b>w2db.php, line ' . __LINE__ . '</b>');
     }
     if ($dbUser == '') {
         die('<b>ERROR:</b> no database user provided... <b>w2db.php, line ' . __LINE__ . '</b>');
     }
     //if ($dbPass == '') die('no database password provided');
     $this->dbName = $dbName;
     // connect
     if ($this->dbType == 'postgres') {
         $this->dbConn = pg_connect("host={$dbIP} " . ($dbPort != null ? "port={$dbPort} " : "") . "dbname={$dbName} user={$dbUser} password={$dbPass}");
         if (!$this->dbConn) {
             $this->dbConn = null;
             print "<b>ERROR:</b> Cannot connect to postgres.<br>";
             return false;
         }
         $this->dbVersion = pg_version($this->dbConn);
         $this->dbVersion['host'] = pg_host($this->dbConn);
     }
     if ($this->dbType == 'mysql') {
         $this->dbConn = mysql_connect($dbIP . ($dbPort != null ? ":" . $dbPort : ""), $dbUser, $dbPass);
         if (!$this->dbConn) {
             $this->dbConn = null;
             print "<b>ERROR:</b> Cannot connect to mysql.<br>";
             return false;
         }
         mysql_select_db($dbName);
         $this->dbVersion = array();
         $this->dbVersion['client'] = mysql_get_client_info();
         $this->dbVersion['protocol'] = mysql_get_proto_info($this->dbConn);
         $this->dbVersion['server'] = mysql_get_server_info($this->dbConn);
         $this->dbVersion['host'] = mysql_get_host_info($this->dbConn);
     }
 }
开发者ID:LeisureLeo,项目名称:w2ui,代码行数:40,代码来源:w2db.php

示例15: connect

 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         $conn = $this->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 (pg_connection_status($this->linkID[$linkNum]) !== 0) {
             throw_exception($this->error(false));
         }
         $pgInfo = pg_version($this->linkID[$linkNum]);
         $this->dbVersion = $pgInfo['server'];
         // 标记连接成功
         $this->connected = true;
         //注销数据库安全信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
开发者ID:dalinhuang,项目名称:concourse,代码行数:31,代码来源:DbPgsql.class.php


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