downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

ibase_wait_event> <ibase_set_event_handler
[edit] Last updated: Fri, 17 May 2013

view this page in

ibase_trans

(PHP 5)

ibase_transInicia uma transação

Descrição

resource ibase_trans ([ int $trans_args [, resource $link_identifier ]] )

Inicia uma transação.

Nota:

O funcionamento desta função mudou no PHP 5.0.0. A primeira chamada a ibase_trans() não irá retornar a transação padrão da conexão. Todas as transações começadas por ibase_trans() seram desfeitas ao final do script se não for gravada ou desfeita por ibase_commit() ou ibase_rollback().

Nota:

No PHP 5.0.0. e posterior, estafunção aceitará multiplos argumentos trans_args e link_identifier. Isto irá permitir transações sobre multiplas conexões de banco de dados, as quais são gravadas usando um algaritimo de duas fases. Isto indica que suas atualizações podem ser bem sucedidas em todos os bancos de dados, ou falhar em todo os bancos de dados. Isto NÃO indica que você possa utilizar tabelas de banco de dados diferentes na mesma consulta!

Se você usar transações em multiplos bancos de dados, você tem que especificar os parâmetros link_id e transaction_id nas chamadas para ibase_query() e ibase_prepare().

Parâmetros

trans_args

trans_args pode ser a combinação de IBASE_READ, IBASE_WRITE, IBASE_COMMITTED, IBASE_CONSISTENCY, IBASE_CONCURRENCY, IBASE_REC_VERSION, IBASE_REC_NO_VERSION, IBASE_WAIT and IBASE_NOWAIT.

link_identifier

Um link identificador InterBase. Se omitido, o último link aberto é usado.

Valor Retornado

Retorna um manipulador de transação, ou FALSE em erro.



ibase_wait_event> <ibase_set_event_handler
[edit] Last updated: Fri, 17 May 2013
 
add a note add a note User Contributed Notes ibase_trans - [3 notes]
up
1
chAlx
1 year ago
Note that on some platforms ibase_trans($dbh), ibase_trans(IBASE_DEFAULT, $dbh) and ibase_trans($dbh, IBASE_DEFAULT) are not the same, but will run without errors in most cases.
up
1
jon at tgpsolutions dot com
10 years ago
When using transactions, you must execute queries using the transaction identifier as the link_identifier in ibase_query. 

Example:

$db = ibase_connect( ... );
$tr = ibase_trans();
$result = ibase_query($tr, $sql1);
$result = ibase_query($tr, $sql2);
ibase_rollback($tr);

You must use ibase_query($tr, $sql1).  Calling ibase_query($db, $sql1) will not allow you to roll back - it will be commited when the script finishes executing.
up
-2
Aaron Brundle
7 years ago
Example of using ibase_trans with ibase_prepare and ibase_execute:

$dbh = ibase_connect( ... );
$sql =  " ... ";
$trans = ibase_trans( IBASE_DEFAULT,$dbh );
$sth = ibase_prepare( $trans, $sql );
$res = ibase_execute( $sth, $params_if_any );
if ($res == false) {
  //log failure if you want
}
ibase_commit($trans);
//free if needed
ibase_free_query($sth);
unset($res);

 
show source | credits | stats | sitemap | contact | advertising | mirror sites