The cci_end_tran function performs a commit or rollback on the current transaction. At this point, all open request handles are terminated and the connection to the database server is disabled. However, even after the connection to the server is disabled, the connection handle remains valid.
You can configure the default value of auto-commit mode by using CCI_DEFAULT_AUTOCOMMIT (broker parameter) upon startup of an application. If configuration on broker parameter is omitted, the default value is ON; use the cci_set_autocommit() function to change auto-commit mode within an application. If auto-commit mode is OFF, you must explicitly commit or roll back transaction by using the cci_end_tran() function.
int cci_end_tran(int conn_handle, char type, T_CCI_ERROR *err_buf)
Auto-commit mode is supported for SELECT statements. To apply this mode, you must add SELECT_AUTO_COMMIT=ON to the cubrid_broker.conf file. However, auto-commit is performed only at the point at which the result set for all n query statements is fetched from the server when there are n prepared statements. An example is as follows:
$sql1 = "select * from db_user";
$sql2 = "select * from db_class where owner_name = ?";
$result = cubrid_execute($con, $sql1); // 1 select handle. fetch completed - autocommit
if ($result) {
while ($row = cubrid_fetch ($result))
{
echo ($row[0]);
$req = cubrid_prepare ($con, $sql2);
cubrid_bind ($req, 1, $row[0]);
$res = cubrid_execute ($req); // 1 select handle. fetch completed - autocommit
}
}
$sql1 = "select * from db_user";
$sql2 = "select * from db_class where owner_name = ?";
$req = cubrid_prepare ($con, $sql2);
$result = cubrid_execute($con, $sql1); // 2 handle. fetch completed for only 1 hanlde - no autcommit
if ($result) {
while ($row = cubrid_fetch ($result))
{
echo ($row[0]);
cubrid_bind ($req, 1, $row[0]);
$res = cubrid_execute ($req); // fetch completed for all select handles - autocommit
}
}
$sql1 = "select * from db_user";
$sql2 = "insert into a values (?)";
$result = cubrid_execute($con, $sql1); // 1 select handle. fetch completed - autocommit
if ($result) {
while ($row = cubrid_fetch ($result))
{
echo ($row[0]);
$req = cubrid_prepare ($con, $sql2);
cubrid_bind ($req, 1, $row[0]);
$res = cubrid_execute ($req); // no autocommit for insert
}
}
$sql1 = "select * from db_user";
$sql2 = "insert into a values (?)";
$req = cubrid_prepare ($con, $sql2);
$result = cubrid_execute($con, $sql1); // no autocommit for insert because no fetch
if ($result) {
while ($row = cubrid_fetch ($result))
{
echo ($row[0]);
cubrid_bind ($req, 1, $row[0]);
$res = cubrid_execute ($req); // no autocommit for insert
}
}