I'm trying to connect to a DB2 (IBM i) database. Can anyone advise how config.php should be setup?
Here is a section of code that I'm using elsewhere that I know is working:
// connect to server…
$db = '*LOCAL' ;
$user = 'PHP_PROD' ;
$pw = '…' ;
$options = array('i5_naming' => DB2_I5_NAMING_ON) ;
if (($dbh = db2_connect($db, $user, $pw, $options)) === false) {
echo 'connection failed.<br>';
echo db2_conn_errormsg().'<br>';
die();
}
Hello,
I've not tested db2 connection but it should be something like:
$db_conf = array();
$db_conf["type"] = "db2"; // for native php driver
$db_conf["server"] = "";
$db_conf["user"] = "PHP_PROD";
$db_conf["password"] = "…";
$db_conf["database"] = "*LOCAL";
include("../../lib/inc/jqgrid_dist.php");
$g = new jqgrid($db_conf);
For DB2_I5_NAMING_ON, you might need to edit:
lib/inc/adodb/drivers/adodb-db2.inc.php
if ($argDatabasename && empty($argDSN)) {
if (stripos($argDatabasename,'UID=') && stripos($argDatabasename,'PWD=')) $this->_connectionID = db2_connect($argDatabasename,null,null);
else $this->_connectionID = db2_connect($argDatabasename,$argUsername,$argPassword);
}
In else, you will need to add options param.
Thanks Abu – this is working now. For any one else working with DB2/i5 (IBM i / iSeries / AS400) here is what I needed to do.
Changed SQL select string in jqgrid_dist.php from:
SELECT a.*,rownum rnum FROM ($V1b1cc7f086b3f074da452bc3129981) a) WHERE …
to:
SELECT a.*, rownumber() over() as rnum FROM ($V1b1cc7f086b3f074da452bc3129981) a) b WHERE …
(changed "rownum" to "rownumber() over()" and added "b" after select end-paren)
And made the following change in lib/inc/adodb/drivers/adodb-db2.inc.php on *both* sides of the IF for I5_NAMING (which searches for a table based on your library list rather than a hardcoded schema):
$options = array('i5_naming' => DB2_I5_NAMING_ON) ;
$this->_connectionID = db2_connect( … ,$options);