Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


PHP ODBC AS400 - When running query new connections to site cant be opened.

Posted on 2009-04-27
Medium Priority
Last Modified: 2013-11-19
Runing Zend/IIS/PHP I have a program that will connect out to our AS/4000 to do some budget cals, however when this is running on the as/400 it prevents any one from accessing the website until the query is done on the as/400 which can be upto 15min.

User 1 goes to website and starts the budget calc process,  User 2 tries to load up the website but cant, basically will sit there waiting for the connection until it times out or User 1's calc finishes and then User 2 can get to the website.

I have mysql queries that take 20min to run and people are able to access the site just fine, only happening when I connect out to the as/400.
Question by:bakes82
  • 2
  • 2
LVL 22

Expert Comment

ID: 24250271
it would seem like you have a single PHP process running in the backend to process requests and that when the SQL call to the AS400 is made it is not spinning it off into a thread so that it locks up PHP and all requests until it has completed executing.

Check you connection code for the PHP database connection and make sure you are in fact using ODBC.  If you are, see if there is a different ODBC client that will work.  This would appear to be an issue with how PHP is interacting with the AS400 database connection ... which means it is either in the code for the connection or with the ODBC drivers.

Author Comment

ID: 24251240
Below is my connection code and one of the files.
The ODBC driver is the official Drive that IBM released from there iSeries client access.  (Guess Ill look and see if I try a diffrent one)
$hostname_as400 = "as400";
$username_as400 = "username";
$password_as400 = "password";
$as400 = odbc_connect($hostname_as400, $username_as400, $password_as400); 
if ($as400 == false) {
echo "Not able to connect to database...<br>";

Open in new window

LVL 22

Accepted Solution

cj_1969 earned 2000 total points
ID: 24251642
As I guessed, PHP is not multi-threaded which means when this executes it is just hanging the entire PHP engine until this completes, keeping it from servicing any other requests.

I found this page (http://www.issociate.de/board/post/259248/Multithreading/Parallel_Processing_with_PHP.html) that has some ideas on how to handle this but none of them looked all that great to me.  I will see what else I can find.  A forking process would be fine if you can pass or access the data from the child process.  Or change your app so that every request that comes into the server is a forked process and then monitor the number of forked processes within the main/parent app.

Author Comment

ID: 24252058
That doesnt seem right, as I run MYSQL queries on the same system for 30-1hr just fine and people are able to still access the site.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question