{"id":1374,"date":"2018-10-14T00:46:11","date_gmt":"2018-10-13T22:46:11","guid":{"rendered":"http:\/\/www.shukko.com\/x3\/?p=1374"},"modified":"2018-10-14T00:46:11","modified_gmt":"2018-10-13T22:46:11","slug":"php-ibm-db2-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.shukko.com\/x3\/2018\/10\/14\/php-ibm-db2-on-centos-7\/","title":{"rendered":"PHP + IBM DB2 on Centos 7"},"content":{"rendered":"<p>Instalation of IBM DB2 module should be very easy (refering to the\u00a0<a href=\"http:\/\/php.net\/manual\/en\/ibm-db2.installation.php\">installation instructions<\/a>):<\/p>\n<ol>\n<li>First of all, we need to download the driver package from\u00a0<a href=\"http:\/\/www-01.ibm.com\/support\/docview.wss?uid=swg21385217\">here<\/a><\/li>\n<li>unpack the package to the server at \/opt\/ibm_db2\/dsdriver<\/li>\n<li>chmod 755 installDSDriver<\/li>\n<li>.\/installDSDriver<\/li>\n<li>Install pecl and php-pear (may need ksh): yum install php-pear<\/li>\n<li>pecl install ibm_db2<\/li>\n<li>When asked, provide the path to the db2 driver (here \/opt\/ibm_db2\/dsdriver)<\/li>\n<li>You may check if it is installed by: pecl list<\/li>\n<li>Last thing: chmod o+w \/opt\/ibm_db2\/dsdriver\/cfg<\/li>\n<li>Edit\u00a0\/etc\/php.ini and add extension=ibm_db2.so<\/li>\n<li>service httpd restart<\/li>\n<\/ol>\n<p>Then in PHP:<\/p>\n<pre class=\"lang:default decode:true  \">&lt;?php\r\n    $databaseName = \"your_db_name\";\r\n    $hostName = \"your_host_name\";\r\n    $port = 50001;\r\n    $userName = \"your_user_name\";\r\n    $password = \"your_password\";\r\n    $conn_string = \"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$databaseName;HOSTNAME=$hostName;PORT=$port;PROTOCOL=TCPIP;UID=$userName;PWD=$password;Security=ssl;\";\r\n    $conn = db2_connect($conn_string, '', '');\r\n\r\n    if($conn) {\r\n        echo \"Connected!\";\r\n        db2_close($conn);\r\n    } else {\r\n        echo \"Not connected&lt;br&gt;\";\r\n        echo db2_conn_errormsg();\r\n    }\r\n?&gt;<\/pre>\n<p>Whole process with lot of pre-requisites for python is <a href=\"https:\/\/www.ibm.com\/developerworks\/community\/blogs\/96960515-2ea1-4391-8170-b0515d08e4da\/entry\/pre-requisites_python_and_ibm_db_driver?lang=en\">here<\/a> (it works with little modifications for PHP too).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Instalation of IBM DB2 module should be very easy (refering to the\u00a0installation instructions): First of all, we need to download the driver package from\u00a0here unpack the package to the server at \/opt\/ibm_db2\/dsdriver chmod 755 installDSDriver .\/installDSDriver Install pecl and php-pear (may need ksh): yum install php-pear pecl install ibm_db2 When asked, provide the path to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1374","post","type-post","status-publish","format-standard","hentry","category-kategerisiz"],"_links":{"self":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/1374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/comments?post=1374"}],"version-history":[{"count":1,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/1374\/revisions"}],"predecessor-version":[{"id":1375,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/1374\/revisions\/1375"}],"wp:attachment":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/media?parent=1374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/categories?post=1374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/tags?post=1374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}