db2_connect isolation level / transactions

General discussion for the Zend Server CE

db2_connect isolation level / transactions

Postby cfunke on Thu Nov 03, 2011 4:28 pm

Hi all,

we have using Zend Server 5.5CE on Ubuntu LTS.
I need to work with a DB2 and db2_connect method. My problem is to configure the right isolation level.

It's very important for us to protect data which is "in transaction" from other processes. If I follow the php manual and set:

$options = array('i5_commit' => DB2_I5_TXN_READ_COMMITTED );
$db2string="DRIVER={IBM DB2 ODBC DRIVER};DATABASE=........";
$conn=db2_connect($db2string, "", "", $options);

I get already two problems:

1st:
Notice: Use of undefined constant DB2_I5_TXN_READ_COMMITTED - assumed 'DB2_I5_TXN_READ_COMMITTED' in /var/www/db2xx.php on line 24

2nd:
Warning: db2_connect() [function.db2-connect]: Incorrect option setting passed in in /var/www/db2c.php on line 28

He does not care about this setting, although php manual describes that this is the right way to configure it.
Also I wonder that I need to use magic function "shutdown" to do a rollback in case of fatal-errors. Otherwise table is locked and data readable for other processes. But this may have the same reason (wrong isolation level).

Please if anyone can help, let me know.

Kind Regards,
Christian Funke
cfunke
 
Posts: 3
Joined: Thu Nov 03, 2011 4:12 pm

Re: db2_connect isolation level / transactions

Postby zvika on Mon Nov 07, 2011 1:20 pm

Hi

Make sure you place this directive in php.ini:
ibm_db2.i5_allow_commit=1

If this doesn't help, please report back the version of PHP-DB2 extension from phpinfo() if shown,
I tested Zend Server 5.5 on Ubuntu 10.04 64 LTS and IBM DB2 version is 1.9.1 (needs to be above 1.5.1 as far as I've read).
Zvika Dror
Zend Support Team
User avatar
zvika
 
Posts: 509
Joined: Sun Dec 14, 2008 9:48 am

Re: db2_connect isolation level / transactions

Postby cfunke on Tue Nov 08, 2011 11:27 am

Thank you, but tis did not help. Here is the information about system:

ibm_db2
IBM DB2, Cloudscape and Apache Derby support enabled
Module release 1.9.1
Module revision $Revision: 305200 $
Binary data mode (ibm_db2.binmode) DB2_BINARY
DB2 instance name (ibm_db2.instance_name) db2inst1

Zend Server Community Edition
Version 5.5.0

PHP
Version 5.3.8-ZS5.5.0
cfunke
 
Posts: 3
Joined: Thu Nov 03, 2011 4:12 pm

Re: db2_connect isolation level / transactions

Postby shlomov on Wed Nov 09, 2011 4:54 pm

The following is a summary of IBM DB2 Connectivity and access, using windows as an example, same is relevant for Linux:

1. Using Zend Server for Linux/Windows to connect to an IBMi, using ODBC:
a. Install an IBM ODBC driver, you can use the IBM Client Access tool (Windows or Linux versions).
b. Create a system DSN using the Windows "ODBC Data Source Administrator" from the "START button" -> "Administrative Tools" -> Data Sources(ODBC) (with windows 7 – run the 32bit version ->C:\Windows\SysWOW64\odbcad32.exe)
c. The DSN holds the connectivity information(ip address, database name and port),

Example:

<?php
$DBUser = "XXXXXX";
$DBPwd = "xxxxxxxx";
$dsn = "SYSDSN";

$link2 = odbc_connect($dsn , $DBUser, $DBPwd) or die(odbc_errormsg() );

$sqlstmt = "select * from shlomophp.empfile"; $result = odbc_exec($link2, $sqlstmt);

while ($row = (odbc_fetch_row($result)))
{ echo (odbc_result($result, 1));
echo " ";
echo (odbc_result($result, 2));
echo " ";
echo (odbc_result($result, 3));
echo " ";
echo (odbc_result($result, 4));
echo " ";
echo (odbc_result($result, 5));
echo "<br><br>"; }
odbc_close($link2);
?>



2. Using Zend Server for Windows/Linux to connect to an IBMi, using DB2 for Linux, UNIX and Windows product:
a. To connect you need the IBM DB2Connect, this product requires a valid license purchased from IBM.
http://www-01.ibm.com/software/data/db2 ... x-windows/
http://www.developers.net/ibmshowcase/view/3149
b. Once you define the IBMi data base to this local DB2 Server you can connect using the db2 extension.
c. Use the i5 command WRKRDBDIRE command to get the database name.

Example:
<?php
$database = 'SAMPLE';
$user = 'db2admiin';
$password = 'db2admin';

$conn = db2_connect($database, $user, $password);

if ($conn) {
echo "Connection succeeded.";
db2_close($conn);
}
else {
echo "Connection failed.";
}
?>

To properly acknowledge your issue please open a support case:
http://www.zend.com/en/support-center/
Shlomo Vanunu
IBM System i
User avatar
shlomov
 
Posts: 126
Joined: Mon Dec 29, 2008 2:38 pm


Return to Zend Server Community Edition

Who is online

Users browsing this forum: No registered users and 0 guests