本文整理汇总了PHP中pg_set_error_verbosity函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_set_error_verbosity函数的具体用法?PHP pg_set_error_verbosity怎么用?PHP pg_set_error_verbosity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_set_error_verbosity函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: __construct
function __construct($params)
{
$this->dbconn = pg_pconnect($params['server']);
if (false === $this->dbconn) {
throw new \Pg\Exception(pg_last_error());
}
if (isset($params['type_converter'])) {
$this->typeConverter = $params['type_converter'];
} else {
$this->typeConverter = new \Pg\TypeConverter();
}
pg_set_error_verbosity($this->dbconn, PGSQL_ERRORS_VERBOSE);
}
开发者ID:aoyagikouhei,项目名称:pg,代码行数:13,代码来源:Db.php
示例3: connect
protected function connect(&$config)
{
if ($this->conn !== null) {
throw new reException('postgres db: already connected');
}
if (($this->conn = pg_connect($config['connection_string'])) === false) {
throw new reException('postgres db connect failed: ' . pg_last_error(null));
}
pg_set_error_verbosity($this->conn, PGSQL_ERRORS_VERBOSE);
if (isset($config['query_log'])) {
$this->query_log = $config['query_log'];
}
}
开发者ID:rfool,项目名称:relational,代码行数:13,代码来源:postgres.php
示例4: connect
/**
* @return PgSQL
**/
public function connect()
{
$conn = "host={$this->hostname} user={$this->username}" . ($this->password ? " password={$this->password}" : null) . ($this->basename ? " dbname={$this->basename}" : null) . ($this->port ? " port={$this->port}" : null);
if ($this->persistent) {
$this->link = pg_pconnect($conn);
} else {
$this->link = pg_connect($conn);
}
if (!$this->link) {
throw new DatabaseException('can not connect to PostgreSQL server: ' . pg_errormessage());
}
if ($this->encoding) {
$this->setDbEncoding();
}
pg_set_error_verbosity($this->link, PGSQL_ERRORS_VERBOSE);
return $this;
}
开发者ID:rero26,项目名称:onphp-framework,代码行数:20,代码来源:PgSQL.class.php
示例5: connect
function connect($force = false)
{
if ($this->isConnected() && !$force) {
return $this;
}
$connectionParameters = array();
$connectionParameters['host'] = (string) $this->getHost();
$connectionParameters['user'] = (string) $this->getUser();
if ($this->getPassword()) {
$connectionParameters['password'] = $this->getPassword();
}
if ($this->getDBName()) {
$connectionParameters['dbname'] = $this->getDBName();
}
if ($this->getPort()) {
$connectionParameters['port'] = $this->getPort();
}
$connectionString = array();
foreach ($connectionParameters as $key => $value) {
$connectionString[] = $key . '=' . $this->getDialect()->quoteValue($value);
}
$connectionString = join(' ', $connectionString);
try {
if ($this->isPersistent()) {
LoggerPool::log(parent::LOG_VERBOSE, 'obtaining a persistent connection to postgresql: %s', $connectionString);
$this->link = pg_pconnect($connectionString);
} else {
LoggerPool::log(parent::LOG_VERBOSE, 'obtaining a new connection to postgresql: %s', $connectionString);
$this->link = pg_pconnect($connectionString, $force ? PGSQL_CONNECT_FORCE_NEW : null);
}
} catch (ExecutionContextException $e) {
LoggerPool::log(parent::LOG_VERBOSE, 'connection to postgresql failed: %s', $e->getMessage());
throw new DBConnectionException($this, "can not connect using {$connectionString}: {$e->getMessage()}");
}
$this->preparedStatements = array();
if ($this->getEncoding()) {
$this->setEncoding($this->getEncoding());
}
pg_set_error_verbosity($this->link, PGSQL_ERRORS_TERSE);
return $this;
}
开发者ID:phoebius,项目名称:ajax-example,代码行数:41,代码来源:PgSqlDB.class.php
示例6: connect
/**
* Connects to a database.
* @return void
* @throws Dibi\Exception
*/
public function connect(array &$config)
{
$error = NULL;
if (isset($config['resource'])) {
$this->connection = $config['resource'];
} else {
$config += ['charset' => 'utf8'];
if (isset($config['string'])) {
$string = $config['string'];
} else {
$string = '';
Dibi\Helpers::alias($config, 'user', 'username');
Dibi\Helpers::alias($config, 'dbname', 'database');
foreach (['host', 'hostaddr', 'port', 'dbname', 'user', 'password', 'connect_timeout', 'options', 'sslmode', 'service'] as $key) {
if (isset($config[$key])) {
$string .= $key . '=' . $config[$key] . ' ';
}
}
}
set_error_handler(function ($severity, $message) use(&$error) {
$error = $message;
});
if (empty($config['persistent'])) {
$this->connection = pg_connect($string, PGSQL_CONNECT_FORCE_NEW);
} else {
$this->connection = pg_pconnect($string, PGSQL_CONNECT_FORCE_NEW);
}
restore_error_handler();
}
if (!is_resource($this->connection)) {
throw new Dibi\DriverException($error ?: 'Connecting error.');
}
pg_set_error_verbosity($this->connection, PGSQL_ERRORS_VERBOSE);
if (isset($config['charset']) && pg_set_client_encoding($this->connection, $config['charset'])) {
throw self::createException(pg_last_error($this->connection));
}
if (isset($config['schema'])) {
$this->query('SET search_path TO "' . $config['schema'] . '"');
}
}
开发者ID:janlanger,项目名称:dibi,代码行数:45,代码来源:PostgreDriver.php
示例7: __construct
/**
* @param ConnectionSettings
*/
public function __construct($connectionSettings, ConnectionFactory $connectionFactory = null)
{
if (!$connectionSettings instanceof ConnectionSettings) {
throw new BadTypeException($connectionSettings, 'Bond\\Pg\\ConnectionSettings');
}
$this->connectionSettings = $connectionSettings;
$connectionString = $this->connectionSettings->getConnectionString();
if (!($resource = @pg_connect($connectionString, PGSQL_CONNECT_FORCE_NEW))) {
$error = error_get_last();
throw new UnableToConnectException($connectionString, $error['message'], $connectionSettings->jsonSerialize());
}
self::$instances[] = $this;
$this->terminated = false;
pg_set_error_verbosity($resource, PGSQL_ERRORS_VERBOSE);
// search path -- this must be sql safe
// possible sql injection vuln here -- setting must be sql injection safe
if (isset($connectionSettings->search_path)) {
pg_query("SET search_path TO {$connectionSettings->search_path};");
}
$this->resource = $resource;
$this->connectionFactory = $connectionFactory;
}
开发者ID:squareproton,项目名称:bond,代码行数:25,代码来源:Resource.php
示例8: connect
/**
* Explicitly connects to the database
*
* @return $this
* @throws exceptions\ConnectionException
*/
public function connect()
{
if ($this->_resource) {
return $this;
}
$connectionWarnings = array();
set_error_handler(function ($errno, $errstr) use(&$connectionWarnings) {
$connectionWarnings[] = $errstr;
return true;
}, E_WARNING);
$this->_resource = pg_connect($this->_connectionString, PGSQL_CONNECT_FORCE_NEW);
restore_error_handler();
if (false === $this->_resource) {
throw new exceptions\ConnectionException(__METHOD__ . ': ' . implode("\n", $connectionWarnings));
}
pg_set_error_verbosity($this->_resource, PGSQL_ERRORS_VERBOSE);
return $this;
}
开发者ID:sad-spirit,项目名称:pg-wrapper,代码行数:24,代码来源:Connection.php
示例9: uf_select_voucher
function uf_select_voucher($ls_chevau)
{
////////////////////////////////////////////////////////////////////////////////////////////////
//
// -Funcion que verifica que retorna true si el vaucher introducido ya existe
// Autor: Ing. Laura Cabre
//
///////////////////////////////////////////////////////////////////////////////////////////////
$dat=$_SESSION["la_empresa"];
$ls_codemp=$dat["codemp"];
$ls_sql="SELECT chevau
FROM scb_movbco
WHERE chevau='$ls_chevau' AND codope='CH' and codemp='$ls_codemp'";
$rs_mov=$this->io_sql->select($ls_sql);
if(($rs_mov===false))
{
pg_set_error_verbosity($this->io_sql->conn, PGSQL_ERRORS_TERSE);
$ls_x=pg_last_error($this->io_sql->conn);
$this->is_msg_error="Error en uf_select_voucher,".$this->io_sql->message;
print $this->is_msg_error;
return false;
}
else
{
if($row=$this->io_sql->fetch_row($rs_mov))
{
if($row["chevau"]!="")
return true;
else
return false;
}
else
{
return false;
}
}
}
开发者ID:ssolano,项目名称:cafe_sigesp,代码行数:38,代码来源:sigesp_scb_c_movbanco.php
示例10: connect
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 1.0
* @throws \RuntimeException
*/
public function connect()
{
if ($this->connection) {
return;
}
// Make sure the postgresql extension for PHP is installed and enabled.
if (!static::isSupported()) {
throw new UnsupportedAdapterException('PHP extension pg_connect is not available.');
}
/*
* pg_connect() takes the port as separate argument. Therefore, we
* have to extract it from the host string (if povided).
*/
// Check for empty port
if (!$this->options['port']) {
// Port is empty or not set via options, check for port annotation (:) in the host string
$tmp = substr(strstr($this->options['host'], ':'), 1);
if (!empty($tmp)) {
// Get the port number
if (is_numeric($tmp)) {
$this->options['port'] = $tmp;
}
// Extract the host name
$this->options['host'] = substr($this->options['host'], 0, strlen($this->options['host']) - (strlen($tmp) + 1));
// This will take care of the following notation: ":5432"
if ($this->options['host'] == '') {
$this->options['host'] = 'localhost';
}
} else {
$this->options['port'] = '5432';
}
}
// Build the DSN for the connection.
$dsn = "host={$this->options['host']} port={$this->options['port']} dbname={$this->options['database']} " . "user={$this->options['user']} password={$this->options['password']}";
// Attempt to connect to the server.
if (!($this->connection = @pg_connect($dsn))) {
$this->log(Log\LogLevel::ERROR, 'Error connecting to PGSQL database.');
throw new ConnectionFailureException('Error connecting to PGSQL database.');
}
pg_set_error_verbosity($this->connection, PGSQL_ERRORS_DEFAULT);
pg_query($this->connection, 'SET standard_conforming_strings=off');
}
开发者ID:jbanety,项目名称:database,代码行数:50,代码来源:PostgresqlDriver.php
示例11: array
}
</style>
</head>
<body>
<h1>Database content</h1>
<?php
require 'db_utils.php';
require 'score.php';
$error = FALSE;
$candidate_peer_infos = array();
function q($txt)
{
return htmlspecialchars($txt, ENT_COMPAT | ENT_HTML401, 'UTF-8');
}
$database = pg_connect("dbname=cadist3d_db user=cadist3d");
pg_set_error_verbosity($database, PGSQL_ERRORS_VERBOSE);
if (!$error) {
$query = 'SELECT * FROM links;';
$result = pg_query($database, $query);
if ($result === FALSE) {
$error = q(pg_last_error($database));
} else {
$links = array();
$n = pg_num_rows($result);
for ($i = 0; $i < $n; $i++) {
$a = pg_fetch_result($result, $i, 'a');
$b = pg_fetch_result($result, $i, 'b');
if (!isset($links[$b])) {
$links[$b] = array();
}
if (!isset($links[$a])) {
开发者ID:Chiru,项目名称:RADE,代码行数:31,代码来源:Show.php
示例12: 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
示例13: connect
/**
* Connection vers le serveur
* @param host addresse de la base de donnees
* @param login nom de l'utilisateur autorise
* @param passwd mot de passe
* @param name nom de la database (ne sert pas sous mysql, sert sous pgsql)
* @param port Port of database server
* @return resource handler d'acces a la base
*/
function connect($host, $login, $passwd, $name, $port=0)
{
if (!$name){
$name="postgres";
}
if (!$port){
$port=5432;
}
$con_string = "host=$host port=$port dbname=$name user=$login password=$passwd";
//print 'xxx'.$con_string;
//$this->db = pg_pconnect($con_string); // To us persistent connection because this one cost 1ms, non ersisten cost 30ms
$this->db = pg_connect($con_string);
if ($this->db)
{
$this->database_name = $name;
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE); // Set verbosity to max
}
return $this->db;
}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:29,代码来源:pgsql.lib.php
示例14: registerUsuario
function registerUsuario($username, $email, $password, $rol, $foto)
{
pg_set_error_verbosity($this->dbConnection, PGSQL_ERRORS_DEFAULT);
if (!empty($foto)) {
$result = pg_query($this->dbConnection, "INSERT INTO usuario (pkusu_id,fkusu_rol_id,usu_correo,usu_nombre,usu_clave,usu_imagen)\n\t\t\t\tVALUES(nextval('usuario_pkusu_id_seq'::regclass), '{$rol}', '{$email}', '{$username}', '{$password}', '{$foto}') RETURNING pkusu_id");
} else {
$result = pg_query($this->dbConnection, "INSERT INTO usuario (pkusu_id,fkusu_rol_id,usu_correo,usu_nombre,usu_clave,usu_imagen)\n\t\t\t\tVALUES(nextval('usuario_pkusu_id_seq'::regclass), '{$rol}', '{$email}', '{$username}', '{$password}', NULL) RETURNING pkusu_id");
}
if (pg_last_error()) {
return $this->result_construct("error", pg_last_error());
} else {
$row = pg_fetch_row($result);
$id = $row['0'];
return $this->result_construct("success", $id);
}
}
开发者ID:atahualpasf,项目名称:hipodromo,代码行数:16,代码来源:dbconnection.inc.php
示例15: update_settings
function update_settings($new_settings)
{
$database = pg_connect("dbname=cadist3d_db user=cadist3d");
pg_set_error_verbosity($database, PGSQL_ERRORS_VERBOSE);
$old_settings = get_settings();
foreach ($new_settings as $new_setting) {
$found = FALSE;
foreach ($old_settings as $old_setting) {
$old_key = $old_setting['key'];
if ($new_setting['key'] == $old_key) {
$new_value = $new_setting['value'];
$found = TRUE;
if ($new_value != $old_setting['value']) {
$query = "UPDATE settings SET value = '{$new_value}'" . " WHERE key = '{$old_key}' ;";
$result = pg_query($database, $query);
}
break;
}
}
}
}
开发者ID:Chiru,项目名称:RADE,代码行数:21,代码来源:db_utils.php
示例16: connect
/**
* Connection vers le serveur
* @param host addresse de la base de donnees
* @param login nom de l'utilisateur autorise
* @param passwd mot de passe
* @param name nom de la database (ne sert pas sous mysql, sert sous pgsql)
* @param port Port of database server
* @return resource handler d'acces a la base
*/
function connect($host, $login, $passwd, $name, $port = 0)
{
// use pg_connect() instead of pg_pconnect():
// To us persistent connection because this one cost 1ms, non persistent cost 30ms
$this->db = false;
// connections parameters must be protected (only \ and ' according to pg_connect() manual)
$host = str_replace(array("\\", "'"), array("\\\\", "\\'"), $host);
$login = str_replace(array("\\", "'"), array("\\\\", "\\'"), $login);
$passwd = str_replace(array("\\", "'"), array("\\\\", "\\'"), $passwd);
$name = str_replace(array("\\", "'"), array("\\\\", "\\'"), $name);
$port = str_replace(array("\\", "'"), array("\\\\", "\\'"), $port);
//if (! $name) $name="postgres";
// try first Unix domain socket (local)
if (!$host || $host == "" || $host == "localhost") {
$con_string = "dbname='" . $name . "' user='" . $login . "' password='" . $passwd . "'";
$this->db = pg_connect($con_string);
}
// if local connection failed or not requested, use TCP/IP
if (!$this->db) {
if (!$host) {
$host = "localhost";
}
if (!$port) {
$port = 5432;
}
$con_string = "host='" . $host . "' port='" . $port . "' dbname='" . $name . "' user='" . $login . "' password='" . $passwd . "'";
$this->db = pg_connect($con_string);
} else {
$this->database_name = $name;
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE);
// Set verbosity to max
}
return $this->db;
}
开发者ID:netors,项目名称:dolibarr,代码行数:43,代码来源:pgsql.lib.php
示例17: 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
示例18: connect
public function connect($param)
{
$dsn = "host={$param['host']} ";
$dsn .= isset($param['port']) ? "port={$param['port']} " : '';
$dsn .= "dbname={$param['dbname']} user={$param['user']} password={$param['pass']}";
if (!($this->link = @pg_connect($dsn))) {
throw new XSException('Error connecting to PGSQL database:' . $param['dbname'] . '.');
pg_set_error_verbosity($this->link, PGSQL_ERRORS_DEFAULT);
pg_query('SET standard_conforming_strings=off');
}
}
开发者ID:flying3615,项目名称:chuniang,代码行数:11,代码来源:XSDataSource.class.php
示例19: connect
/**
* Connexion to server
*
* @param string $host Database server host
* @param string $login Login
* @param string $passwd Password
* @param string $name Name of database (not used for mysql, used for pgsql)
* @param string $port Port of database server
* @return resource Database access handler
* @see close
*/
function connect($host, $login, $passwd, $name, $port = 0)
{
// use pg_pconnect() instead of pg_connect() if you want to use persistent connection costing 1ms, instead of 30ms for non persistent
$this->db = false;
// connections parameters must be protected (only \ and ' according to pg_connect() manual)
$host = str_replace(array("\\", "'"), array("\\\\", "\\'"), $host);
$login = str_replace(array("\\", "'"), array("\\\\", "\\'"), $login);
$passwd = str_replace(array("\\", "'"), array("\\\\", "\\'"), $passwd);
$name = str_replace(array("\\", "'"), array("\\\\", "\\'"), $name);
$port = str_replace(array("\\", "'"), array("\\\\", "\\'"), $port);
if (!$name) {
$name = "postgres";
}
// When try to connect using admin user
// try first Unix domain socket (local)
if (!empty($host) && $host == "socket" && !defined('NOLOCALSOCKETPGCONNECT')) {
$con_string = "dbname='" . $name . "' user='" . $login . "' password='" . $passwd . "'";
// $name may be empty
$this->db = @pg_connect($con_string);
}
// if local connection failed or not requested, use TCP/IP
if (!$this->db) {
if (!$host) {
$host = "localhost";
}
if (!$port) {
$port = 5432;
}
$con_string = "host='" . $host . "' port='" . $port . "' dbname='" . $name . "' user='" . $login . "' password='" . $passwd . "'";
$this->db = @pg_connect($con_string);
}
// now we test if at least one connect method was a success
if ($this->db) {
$this->database_name = $name;
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE);
// Set verbosity to max
}
return $this->db;
}
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:50,代码来源:pgsql.class.php
示例20: connect
/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 12.1
* @throws RuntimeException
*/
public function connect()
{
if ($this->connection) {
return;
}
// Make sure the postgresql extension for PHP is installed and enabled.
if (!function_exists('pg_connect')) {
throw new RuntimeException('PHP extension pg_connect is not available.');
}
// Build the DSN for the connection.
$dsn = '';
if (!empty($this->options['host'])) {
$dsn .= "host={$this->options['host']} ";
}
$dsn .= "dbname={$this->options['database']} user={$this->options['user']} password={$this->options['password']}";
// Attempt to connect to the server.
if (!($this->connection = @pg_connect($dsn))) {
throw new RuntimeException('Error connecting to PGSQL database.');
}
pg_set_error_verbosity($this->connection, PGSQL_ERRORS_DEFAULT);
pg_query('SET standard_conforming_strings=off');
pg_query('SET escape_string_warning=off');
}
开发者ID:Rajiii4u,项目名称:joomla-cms,代码行数:31,代码来源:postgresql.php
注:本文中的pg_set_error_verbosity函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论