Access DB2 through “ibm_db2” extension

phpgrid db2
* Access to DB2 through “ibm_db2” extension is only supported in the commercial license.

 

phpgrid_ibm_db2

phpGrid now supports IBM DB2 Universal Database through “ibm_db2” extension that uses native IBM DB2 functions. It’s faster and more efficient than using PDO_ODBC driver. Simply define “PHPGRID_DB_TYPE” value as “db2” in the conf.php file. You should use “*LOCAL” or database IP address as the “PHPGRID_DB_HOSTNAME”.

1
2
3
4
5
6
define('PHPGRID_DB_HOSTNAME','*LOCAL'); // database host name
define('PHPGRID_DB_USERNAME', '');     // database user name
define('PHPGRID_DB_PASSWORD', ''); // database password
define('PHPGRID_DB_NAME', 'SAMPLE'); // database name
define('PHPGRID_DB_TYPE', 'db2');  // database type
define('PHPGRID_DB_OPTIONS', serialize(array('i5_lib'=>'CLASSICMODELS', 'i5_naming' => DB2_I5_NAMING_ON)));
Notice the new “PHPGRID_DB_OPTIONS” constant, it defines the value for the last paramter “$options” in db2_connect function. In this constant, you can set values for the i5_* options.
X

Below is the phpGrid code sample:

1
2
3
4
5
6
7
8
9
10
11
12
$dg = new C_DataGrid("SELECT * FROM STAFF", "ID", "STAFF");
$dg->set_col_title('NAME', 'Last Name')->set_col_readonly('NAME');
$dg->enable_search(true);
$dg->enable_export('PDF');
$dg->enable_edit('FORM');
$dg->set_col_required('DEPT');
//$dg->set_col_edittype('COUNTRY', 'select', ':;');
$dg->set_conditional_format("COMM","CELL",array(
   "condition"=>"gt","value"=>1000,"css"=> array("color"=>"black","background-color"=>"lightgreen")));

$dg -> set_databar("SALARY","blue", 120000)->set_col_width('SALARY', '190px');
$dg -> display();

That’s all there is to it. Happy Gridding!