Harrie's blog
Friday, 8 June 2007PHP for IBM i5: how to control your library list from PHPTrackbacks
PHP on IBM's System-i
Some of the developers at Ibuildings are working with PHP on IBM's System-i platform. If that name doesn't ring a bell, it has been called 'iSeries' for a while and it's basically a new name for the old AS/400. If you're old enough to remember Happy Days
Weblog: ATK rules...
Gevolgd: Jun 08, 19:36 Reacties
Geeft reacties weer als
(Lineair | Samengevoegd)
Thank you for the information.
I Tried it on our i5. I have just one question. It seems, that the added libs are at the bottom of the liblist. It their any way to put the added libs to the top? Thanx Bernd
Hi Bernd, thanks for your reply. The command that is executed is:
CODE: i5_command("chglibl",array("libl"=>$curlibl),array(),$conn) This works the same way as the 'chglibl' command on the i5 green screen. The parameter I pass ($curlibl) is a string containing "existinglib1 existinglib2 newlib1 newlib2", but you could just as easy change the order of that in anything you like. If you want to swap them (first the new libraries and than the old ones) you whould have to alter the line: CODE: $curlibl .= " " . implode(" ",$libraries); into: CODE: $curlibl = implode(" ",$libraries) . " " . $curlibl; I haven't tried this but I suppose this should work just as well. If you are planning to try this could you let me know if it worked?
Harrie, I hope this response works ok. I have tried your code and it works... Thank you very much for posting this. I tried with a I5 connection without db name, user name, password, and it didn't work. So I tried with connection parameters and it did! This will be extremely helpful for us, I am sure. Again, many thanks.
As a note to others, during my testing, I realized that this is allowing me to add libraries to those that are already in the system value QUSRLIBL. If those libraries are already in the user library list, then this CHGLIBL command will fail. Chuck
Very useful post. Thanks.
In Java, if the JDBC connection uses "naming=system" then the Library List of the user the connection signed on with will be used. This worked well because the code didn't know about library lists. If the DB connection is made with TESTuser, then the test library list associated with that user profile is used. Getting the DB connection using PRODuser gets the production library list associated with PRODuser's profile. To change the library list, use the command CHGJOBD for the job description associated with the user profile. Will that scheme work in PHP? (I'm just starting to code with PHP. I'm coding at home using MySQL)
Hi Greg, interesting question. Just like you are new to PHP, I'm new to IBM i5 so I hope I get your question right.
You can pass the option 'I5_OPTIONS_SQLNAMING' to the i5_connect function to specify what naming to use, like this: CODE: $conn_resource = i5_connect('127.0.0.1',$user,$password,array(I5_OPTIONS_SQLNAMING=>"SQL")); (use SQL naming) or CODE: $conn_resource = i5_connect('127.0.0.1',$user,$password,array(I5_OPTIONS_SQLNAMING=>"SYS")); (use SYSTEM naming) Also, I believe you can assign certain librarylists to different users on the IBM i5. I think it should work fine if you create a user called 'test' with a certain librarylist and use this username in your i5_connect() command. The librarylist should be the same as the librarylist specified for that user. You could try this very easy by creating or modifying a user and define a librarylist for that user. Than in PHP connect using that user and do this to check if it works: CODE: i5_command("rtvjoba",array(),array("usrlibl"=>"curlibl")); echo ("Current librarylist: " . $curlibl); It should display the librarylist you have defined for that user. If that is the case, the queries you execute using i5_query() use the same librarylist. This off course is the ultimate reason why librarylists exist: if you move your application to 'production' the only thing that you have to do is changing the username that you use, and automatically the correct libraries will be used. In addition, you could do something like: CODE: if (strstr($_SERVER['HTTP_HOST'],"staging")) $username = "testuser"; else $username = "productionuser"; i5_connect("127.0.0.1",$username .... so when your domainname has the word 'staging' in it (like staging.mydomain.com) your application will use the 'testuser' username to connect, and when it doesn't (www.mydomain.com) it will use the 'productionuser' to connect. This way you don't need to change code at all when moving your application from staging to production or back - but your application will auto-detect what username to use (and so the librarylist will be correct as well). I hope this answered your question. |
Blog











