本文整理汇总了PHP中pg_transaction_status函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_transaction_status函数的具体用法?PHP pg_transaction_status怎么用?PHP pg_transaction_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_transaction_status函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: inTransaction
/**
* testa se a existe transacao ativa na conexao corrente;.
* @return boolean
*/
function inTransaction()
{
global $conn;
$isIntransaction = false;
$lStatus = pg_transaction_status($conn);
switch ($lStatus) {
// sem transacao em (0)
case PGSQL_TRANSACTION_IDLE:
$isIntransaction = false;
break;
//em Transacao Ativa, comando sendo executado (1)
//em Transacao Ativa, comando sendo executado (1)
case PGSQL_TRANSACTION_ACTIVE:
$isIntransaction = true;
break;
//transacao em andamento (2)
//transacao em andamento (2)
case PGSQL_TRANSACTION_INTRANS:
$isIntransaction = true;
break;
//transacao com erro (3)
//transacao com erro (3)
case PGSQL_TRANSACTION_INERROR:
$isIntransaction = false;
break;
//falha na conexao; (4);
//falha na conexao; (4);
case PGSQL_TRANSACTION_UNKNOWN:
$isIntransaction = false;
break;
}
return $isIntransaction;
}
示例3: inTransaction
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
return !in_array(pg_transaction_status($this->connection), array(PGSQL_TRANSACTION_UNKNOWN, PGSQL_TRANSACTION_IDLE), TRUE);
}
示例4: update
public function update()
{
$this->mNewState = array(pg_connection_status($this->mConn), pg_transaction_status($this->mConn));
}
示例5: inTransaction
/**
* Checks whether a transaction is currently open.
*
* @return bool
*/
public function inTransaction()
{
$status = pg_transaction_status($this->getResource());
return PGSQL_TRANSACTION_INTRANS === $status || PGSQL_TRANSACTION_INERROR === $status;
}
示例6: getTransactionStatus
/**
* getTransactionStatus
*
* Return the current transaction status.
* Return a PHP constant.
* @see http://fr2.php.net/manual/en/function.pg-transaction-status.php
*
* @access public
* @return int
*/
public function getTransactionStatus()
{
return pg_transaction_status($this->handler);
}
示例7: rollback
rollback($savepoint=NULL){$this->query($savepoint?"ROLLBACK TO SAVEPOINT $savepoint":'ROLLBACK');}function
inTransaction(){return!in_array(pg_transaction_status($this->connection),array(PGSQL_TRANSACTION_UNKNOWN,PGSQL_TRANSACTION_IDLE),TRUE);}function
示例8: __destruct
/**
* Деструктор. Закрывает открытую транзакцию и записывает в файл(ы) debug информацию.
*
*/
public function __destruct()
{
--self::$objects;
if ($this->debugLog) {
$log = new log("db/" . $this->alias . "/debug/" . $this->debug);
for ($i = 0; $i < count($this->debugLog); $i++) {
$log->writeln($this->debugLog[$i]['text']);
}
}
$log = new log("db/" . $this->alias . '/' . date('Y-m-d') . ".log");
if ($this->log) {
$log->writeln($this->log);
}
if ($this->_transaction) {
$rollback = false;
$xstat = pg_transaction_status($this->_transaction);
$xcodes = array(PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN', PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE', PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS', PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR', PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE');
switch ($xstat) {
case PGSQL_TRANSACTION_INTRANS:
case PGSQL_TRANSACTION_INERROR:
case PGSQL_TRANSACTION_ACTIVE:
$rollback = true;
break;
}
if ($rollback) {
$err = "Transaction status is BAD and it rollbacked: {$xcodes[$xstat]}, name=" . $this->alias;
$this->rollback();
} else {
$err = "Transaction counter is BAD on DESTRUCT: status {$xcodes[$xstat]}";
$this->_transaction = NULL;
}
$this->err($err);
}
if (!self::$objects) {
setLastUserAction();
if (DB::$_stby_log) {
// можно убрать, отладочное.
$stby_db = new DB('stat');
setlocale(LC_ALL, 'en_US.UTF-8');
foreach (DB::$_stby_log as $key => $val) {
list($val['day'], $val['real_mask'], $val['opts']) = explode('=', $key);
$sql = "\n UPDATE stby_log2\n SET master_cnt = master_cnt + ?i, standby_cnt = standby_cnt + ?i,\n master_time = master_time + interval ?, standby_time = standby_time + ?, ro_errors_cnt = ro_errors_cnt + ?i\n WHERE day = ? AND opts = ? AND real_mask = ?i\n ";
$res = $stby_db->query($sql, (int) $val['master_cnt'], (int) $val['standby_cnt'], (double) $val['master_time'] . ' seconds', (double) $val['standby_time'] . ' seconds', (int) $val['ro_errors_cnt'], $val['day'], $val['opts'], (int) $val['real_mask']);
if (!pg_affected_rows($res)) {
$sql = "\n INSERT INTO stby_log2 (master_cnt, standby_cnt, master_time, standby_time, ro_errors_cnt, day, opts, real_mask)\n VALUES (?i, ?i, ?, ?, ?i, ?, ?, ?i)\n ";
$stby_db->query($sql, (int) $val['master_cnt'], (int) $val['standby_cnt'], (double) $val['master_time'] . ' seconds', (double) $val['standby_time'] . ' seconds', (int) $val['ro_errors_cnt'], $val['day'], $val['opts'], (int) $val['real_mask']);
}
}
}
DB::$_stby_log = array();
}
}
示例9: status
function status()
{
return pg_transaction_status($this->db);
}
示例10: pg_pconnect
// connection function tests
include 'config.inc';
$db = pg_pconnect($conn_str);
var_dump($db);
if (pg_connection_status($db) != PGSQL_CONNECTION_OK) {
echo "pg_connection_status() error\n";
}
if (!pg_connection_reset($db)) {
echo "pg_connection_reset() error\n";
}
if (pg_connection_busy($db)) {
echo "pg_connection_busy() error\n";
}
if (function_exists('pg_transaction_status')) {
if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE) {
echo "pg_transaction_status() error\n";
}
}
if (false === pg_host($db)) {
echo "pg_host() error\n";
}
if (!pg_dbname($db)) {
echo "pg_dbname() error\n";
}
if (!pg_port($db)) {
echo "pg_port() error\n";
}
if (pg_tty($db)) {
echo "pg_tty() error\n";
}
示例11: rollback
/**
* Reverts the current transaction
*
* @return int DB_OK on success. A DB_Error object on failure.
*/
function rollback()
{
if (pg_transaction_status($this->connection) == PGSQL_TRANSACTION_INTRANS) {
$this->transaction_opcount = 1;
}
if ($this->transaction_opcount > 0) {
$result = @pg_exec($this->connection, 'abort;');
$this->transaction_opcount = 0;
if (!$result) {
return $this->pgsqlRaiseError();
}
}
return DB_OK;
}