Persistent Connections to Oracle databases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
 
I'm new in PHP, but I have already written a lot of pages using Perl. Now I would to rewrite some modules of my web application in PHP but I have a problem with persistent connections to Oracle databases.
 
My understanding of persistent connections was that using the ociplogon function a connection would be opened to the database and all other connections to the same database (with the same username and password) would use the first one previously opened, which mean I would have only 1 connection to the database. But in fact it is not what is happening, every time I submit the page to the same database a new connection is opened. Which is a little bit annoying if I submit this one 100 times (100 connections at the end).
 
How could I manage persistent connections using ociplogon? Is there some parameters to add in the http.conf file. I use PHP5, apache 1.3.28, and for Oracle 8i and 9i.
 
Below is one page of my application. I hope that someone will be able to help me.
 
<?php header ("Cache-Control:no-cache");
 $user_name = $HTTP_GET_VARS["user_name"];
 $atod_password = $HTTP_GET_VARS["password"];
 $type = $HTTP_GET_VARS["type"];
 $owner = $HTTP_GET_VARS["owner"];
 $db_name = $HTTP_GET_VARS["database_name"];
 $db_conn = ociplogon ( $user_name, $atod_password, "ATOD" );
 $cmdstr = "select password from ATOD.DATABASE_INFO where " .
     "database_name = '" . $db_name . "'";
 $parsed = ociparse ($db_conn, $cmdstr);
 ociexecute ($parsed);
 ocifetch ($parsed);
 $db_password = ociresult($parsed, PASSWORD);
    function fct_invalid_objects ($db, $psswd = "MANAGER", $owner, $type)
 {
  $dbh = ociplogon ( "SYSTEM", $psswd,  $db );
  $sqlstr = "SELECT object_name, object_id, " .
          "TO_CHAR(created, 'dd/mm/yyyy hh24:mi:ss') AS CREATED, " .
          "TO_CHAR(last_ddl_time, 'dd/mm/yyyy hh24:mi:ss') AS LAST_DDL_TIME " .
          "FROM dba_objects WHERE owner = '" . $owner . "' AND " .
          "object_type = '" . $type . "' AND status = 'INVALID' " .
          "ORDER BY 2, 1";
  $parsed = ociparse ($dbh, $sqlstr);
  ociexecute ($parsed);
  $nrows = ocifetchstatement($parsed, $results);
  
  for ( $i = 0; $i < $nrows; $i++ )
  {
   $objects .= "<tr>\n";
   $objects .= "<td>" . $results["OBJECT_NAME"][$i] . "</td>";
   $objects .= "<td>" . $results["OBJECT_ID"][$i] . "</td>";
   $objects .= "<td>" . $results["CREATED"][$i] . "</td>";
   $objects .= "<td>" . $results["LAST_DDL_TIME"][$i] . "</td>";
   $objects .= "</tr>\n";
  }
  return $objects;
 }
?>
<HTML>
<HEAD>
 <title>Web Administration Tool for ORACLE Databases</title>
</HEAD>
<BODY background="http://esorclupg/backgrnd.gif"; link=darkblue alink=red>
 <H2 align=center>Invalid <?php echo $type ?> for user
  <?php echo $owner ?> in <?php echo $db_name ?>
 </H2>
 <TABLE align=center border=5 cols=5 bordercolordark=red bordercolorlight=pink
     cellspacing=5 cellpadding=3 bgcolor=lightblue rules=none frame=box>
  <TR>
   <TH>Object name</TH>
   <TH>Object ID</TH>
   <TH>Created</TH>
   <TH>Last DDL Time</TH>
  </TR>
  <?php echo fct_invalid_objects($db_name, $db_password, $owner, $type) ?>
 </TABLE>
</BODY>
</HTML>

Regards
 
Patrick David

		
---------------------------------
 ALL-NEW Yahoo! Messenger - all new features - even more fun!  

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux