Monthly Archives: January 2017

How to Install PHP 7.0.13 and Nginx 1.11.8 from Perzl on IBM i using PHP-FPM

Below is a simple way of installing RPMs needed to get PHP 7.0.13 & Nginx 1.11.8-1 running on an IBM i Power System.  By the end of it you’ll be able to send http requests to http://yoursite.com:61183/ that are answered by nginx and passed to php-fpm to process.

Advertisements

Setting the Zend DB DB2 connection’s library list to the user’s library list

Recently a friend ran into this issue. One way to correct this issue is to set the i5_libl option on the db2 connection options (http://php.net/manual/en/function.db2-connect.php). Another way to do this is by changing the job description associated with the IBM i user profile by using the command CHGJOBD in a 5250 session. You would set the INLLIBL to LIBL (library list) you want to use. Then assign the jobd
(job description) to user profile your connecting with DB2_connect or Zend_DB and the ibmdb2 adapter.

For example:

CHGJOBD JOBD(MYJOBD) INLLIBL(&MYLIB &ANOTHERLIB)

Then associate this jobd with the user profile

To Debug the issue there are a few DB2 for i services you can call from PHP via SQL and they are:

Clean phone number field with IBM DB2 for i SQL REGEXP_REPLACE

Say you have a phone number in various formats but you just want the numeric characters and all the non-numeric characters removed. Well use the SQL function REGEXP_REPLACE and look for characters with the regular expression [^\d] and replace it with empty character ”. [^\d] is a negated set which means match any characters not in between [^ and ]. \d is a short hand way of saying all digit characters 0-9.

SELECT PHONE_NUMBER, REGEXP_REPLACE(PHONE_NUMBER,'[^\d]’,”)
FROM MYTABLE;

123-123-1234,1231231234

References:
IBM documentation on REGEXP_REPLACE
http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/db2/rbafzscaregexp_replace.htm

Online regex tester tool
http://regexr.com/