RPG, PHP and MYSQL

July 26, 2017

RPG, PHP and MYSQL

By NickLitten

July 26, 2017

php, RPG, SQL

I wish I could take credit for this article. But I cant 🙂  It hits the nail on the head and the author (Daniel Gray) explains himself very clearly:

Getting up to speed with PHP on the IBM I

If I can, I’d like to offer my IBM I friends some advice on getting up to speed on using PHP on IBM I.

The first one: If you are an RPG programmer, there is a decent chance that you aren’t terribly familiar with SQL access. If this is the case, bone up on SQL and start writing your RPG programs to use SQL access rather than record-level access. That’s right, get rid of any DB Table F-Specs in your new RPG programs and use D-Specs and SQL. If you can’t learn how to manipulate data using SQL, there is a good chance that you will never be able to get a job in anything other than RPG. It’s just one of those modern adaptation things, like breathing and walking upright.

The second one: Get yourself a copy of MySQL and ZendServer CE, install them on your personal laptop, and run through some tutorials on doing basic things like reading and writing a MySQL database with PHP. Why do I suggest this? Because it doesn’t cost you a dime, you don’t have to get approval from your boss, and you won’t hose your IBM I PHP applications and DB2 database if someone else is doing something on the system. This removes any barrier to entry for you learning it, so you don’t have any excuses for not learning. Don’t worry so much about anything IBM I or DB2 specific at this point. What is important is that you learn how to perform CRUD functions using SQL in a language that isn’t RPG.

The third one: Once you are somewhat familiar with performing CRUD functions with PHP and MySQL on your local workstation, start using Zend Framework. In particular, start using Zend_Db. Use the Zend:Db::Factory() to create a model instance that uses the MySQL adapter, and start doing CRUD functions using your implementation of Zend_Db on your local workstation.

Once you have taken care of the first three steps, the fourth one is kind of conditional.
– If your boss is okay with you creating yourself a development schema (library) in DB2 on the IBM I.
– If you have IBM DB2 Connect, install that on your laptop and get the latest DB2 drivers for PHP installed, change your Zend_Db2 implementation to use the DB2 adapter, giving it the connect info for your IBM I. Your test script will work fine, no change other than the adapter from MySQL to DB2. Your local workstation will serve as your web server and the IBM I will serve as your DB host.
– If your boss is cool with letting you at the Apache and PHP configs on the IBM I, create yourself a vhost, copy your PHP scripts to it, change the adapter to DB2, and go. The IBM I serves as both your web server and db2 host.

Why don’t I suggest using the IBM I toolkit? Well I’m sure I will have objections, but my opinion is that it really isn’t in your best interest to do so. Using the IBM I toolkit requires that you have an IBM I on the other end serving as your DB host, and if you are trying to learn on your own that throws up a huge barrier to entry. It also introduces a few ‘crutches’ like pseudo-RLA, which doesn’t serve your long-term interests IMHO.

As for program calls, I avoided the toolkit as well and instead I favored the stored-procedure route. About the only reason I could think of for using the toolkit is for the 5250 bridge, but then again, if you are using the 5250 bridge, you probably aren’t really interested in PHP and portability, you are still stuck on RPG.

An additional tip: Check into one of Mike Pavlak’s online crash courses.

Those are my thoughts anyway, you get what you paid for 🙂

-Daniel Gray

I couldnt agree more Dan. I originally went down a similar route but with one small exception. Rather than ask the Boss for space to play on the work’s iSeries – I surfed around eBay and bought my own. An iSeries Server running IBMi 5+ costs less than a laptop…. and its a perfect playing ground.

In this article Mike Pavlak is mentioned – he is a PHP expert and works for ZEND. His blog is an interesting read and can be found here

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

>