Jump to content

Oracle Persistent Connection


wesso

Recommended Posts

Hi

I have recently configured php4 and Apache to works fine with Oracle 10g database on windows.

 

The oracle 10g does have Apache and PHP modules built in. And all work fine.

 

I have tried to use (ociplogon) instead of (OCILogon) and it works fine by establishing many child process connections.

But they will run for ever..

 

Is there any way to kill the child processes after a defined timeout or for example to kill the process that has been inactive for while.

 

(PS: why having many connections to the database that is not been used for while)

 

If there is no function in PHP to do that, can you so please help with a script code to do that.

 

Here is how my simple php script looks like:

 

-----------------------------------------------------------------------------

 

<?php

 

$db_conn = ociplogon( "king", "camilla", "PROD" );

 

$cmdstr = "select FIRSTNAME, LASTNAME from person where ID BETWEEN 14106 AND 14125";

 

$parsed = ociparse($db_conn, $cmdstr);

ociexecute($parsed);

 

$nrows = ocifetchstatement($parsed, $results);

 

 

echo "<html><head><title>Oracle PHP Test</title></head><body>";

echo "<center><h2>Oracle PHP Test</h2><br>";

echo "<table border=1 cellspacing='0' width='50%'>\n<tr>\n";

echo "<td><b>Name</b></td>\n<td><b>Salary</b></td>\n</tr>\n";

 

for ($i = 0; $i < $nrows; $i++ )

{

echo "<tr>\n";

echo "<td>" . $results["FIRSTNAME"][$i] . "</td>";

echo "<td>" . $results["LASTNAME"][$i] . "</td>";

//echo "<td>$ " . number_format($results["PERSONMASTER_ID"][$i], 2). "</td>";

echo "</tr>\n";

}

 

echo "<tr><td colspan='2'> Number of Rows: <B>$nrows</B></td></tr></table>";

echo "<br><em>Tillykke Wessam!</em><br></center></body></html>\n";

 

ocilogoff($db_conn);

 

?>

 

-----------------------------------------------------------------------------

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.