本文整理汇总了PHP中pg_set_error_verbosity函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_set_error_verbosity函数的具体用法?PHP pg_set_error_verbosity怎么用?PHP pg_set_error_verbosity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_set_error_verbosity函数的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;
}
示例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);
}
示例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'];
}
}
示例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;
}
示例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;
}
示例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'] . '"');
}
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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');
}
示例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])) {
示例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";
示例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;
}
示例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);
}
}
示例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;
}
}
}
}