php-firebird icon indicating copy to clipboard operation
php-firebird copied to clipboard

Confusing PHP documentation for ibase_trans()

Open mlazdans opened this issue 11 months ago • 2 comments

Reading the PHP documentation, it appears that the order in which we pass link_identifier and trans_args arguments to ibase_trans() does not matter.

Image

However, this is not quite true. If link_identifier is specified first, then the trans_args are silently ignored. Either do not specify link_identifier, or pass it as the last argument.

Upon examining the source code for ibase_trans() it seems that if you want to specify one or more link_identifier then the order should be like this:

ibase_trans(...0 or more trans args..., $db1, ...0 or more trans args..., $db2, ...etc);

I.e. you first specify transaction parameters, followed by link identifier.

I think either documentation should be updated or ibase_trans() should be fixed or at least throw some warning.

Code to reproduce

<?php

$database = "localhost/3070:/opt/db/test.fdb";
$username = "sysdba";
$password = "masterkey";
$charset = "utf-8";

$db = ibase_connect($database, $username, $password, $charset) or die("Could not connect");
$tr = ibase_trans($db, IBASE_READ) or die("Could not create transaction");
ibase_query($tr, "INSERT INTO TEST_TABLE (INT_128) VALUES(123)") or die("Could not insert");
ibase_commit($tr) or die("Could not commit transaction");;
print "Finished OK\n";

Just swap arguments to make it respect transaction parameters: $tr = ibase_trans(IBASE_READ, $db) or die("Could not create transaction");

mlazdans avatar Mar 03 '25 01:03 mlazdans

You're absolutly right. I added a test case checking the correct order.

I also created a pull request for the PHP docs.

MartinKoeditz avatar Apr 09 '25 12:04 MartinKoeditz

Checked the docs. Not merged yet.

MartinKoeditz avatar Apr 24 '25 13:04 MartinKoeditz

@MartinKoeditz did they merge? Do you have link for that merge request?

mlazdans avatar Nov 09 '25 12:11 mlazdans