php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1026 access on database is very slow
Submitted: 1999-01-04 15:26 UTC Modified: 1999-06-01 16:17 UTC
From: carmelo at melting-soft dot com Assigned:
Status: Closed Package: Reproducible Crash
PHP Version: 3.0.6 (the short desc is not accurate, I think it is a program crash and not a bad database acces) OS: windows-nt (how to change short
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: carmelo at melting-soft dot com
New email:
PHP Version: OS:

 

 [1999-01-04 15:26 UTC] carmelo at melting-soft dot com
- I use php-lib on my system and I changed from
- 3.05 to 3.06.
- I found that the connections to the database become very - slow.
- I am using windows-nt 4 with a sybase sql anywhere database 
- through an odbc driver.

here is a more accurate account of the way to reproduce
the bug for an easier correction.

I use php-lib with php 3.06 on windows NT with
a sql anywhere (sqlnt55) database using the odbc driver.
When i execute the following script, the php process 
never end and my browser give a never ending
"Transferring data from <server>".
This script work well with the same config on php 3.05.
you will find below all what you need for the reproduction
of the bug.
here is the definition of the table :
# ============================================================
#   Table : DATA_INTR                                         
# ============================================================
create table DATA_INTR
(
    DATA_TYPE                  char(3)                        ,
    DATA_CODE                  char(3)                        ,
    DATA_TEXT                  char(32)                       ,
    CODE_LANG                  char(3)                        
);
here are the data :
$db->query("insert into DATA_INTR(DATA_TYPE, DATA_CODE, DATA_TEXT, CODE_LANG) values ('LNG', 'FR', 'Francais', '' )");
$db->query("insert into DATA_INTR(DATA_TYPE, DATA_CODE, DATA_TEXT, CODE_LANG) values ('LNG', 'UK', 'Anglais', '' )");
$db->query("insert into DATA_INTR(DATA_TYPE, DATA_CODE, DATA_TEXT, CODE_LANG) values ('LNG', 'NL', 'N??rlandais', '' )");

here is the offending script:

-------------------------------
bug.php3
-------------------------------
<%
  require "prepend.phl";

  page_open(array("sess" => "Stock_Session", "auth" => "Stock_Challenge_Auth", "perm" => "Stock_Perm"));
  $perm->check("admin");
%>
<html>
<body>
<%
  $db=new DB_stock;
  $db->query("select * from DATA_INTR where DATA_TYPE='LNG' order by DATA_TYPE");
   $lb=new Listbox;
   $lb->show_result($db, "DATA_TEXT", "DATA_CODE", "CODE_DEVS", $CODE_DEVS);
  $db=new DB_stock;
  $db->query("select * from DATA_INTR where DATA_TYPE='LNG' order by DATA_TYPE");
   $lb=new Listbox;
   $lb->show_result($db, "DATA_TEXT", "DATA_CODE", "CODE_DEVS", $CODE_DEVS);
  echo "f fuck";
%>
</body>
</html>
<%
  page_close();
%>
-------------------------------
prepend.phl:
-------------------------------
<?php
  
if (!$prepend) {
  error_reporting(5);
  $theroot="/inetpub/wwwroot";
  $thedoc="/pfconcept";
  $thelang="fr";

  require "$theroot/phlib/db_odbc.inc";
  require "$theroot/phlib/session.inc";
  require "$theroot/phlib/auth.inc";
  require "$theroot/phlib/user.inc";
  require "$theroot/phlib/perm.inc";
  require "$theroot/phlib/table.inc";
  require "$theroot/phlib/page.inc";
  require "$theroot/estock/listbox.inc";
  require "$theroot/estock/local.inc";

class DB_stock extends DB_Sql {
  var $Host     = "";         
  var $Database = "pfconcept";      
  var $User     = "DBA";            
  var $Password = "sql";   

  function import_record_vars() {
    while (list($key, $val) = each($this->Record))
    if (ereg("[A-Za-z][A-Za-z0-9_]*", $key)) {
      $field_name = strtoupper($key); 
	  global $$field_name;
	  //echo "$field_name, $val";
	  $$field_name=$val;
    }; 
  }

  function dump_table($tablename, $filter="") {
    $this->query(sprintf("select * from %s", $tablename));
    while ($this->next_record()) {
	  $this->dump_record($tablename, $filter);
	};
  }

  function dump_query($tablename, $filter="") {
    //$this->query(sprintf("select * from %s", $tablename));
    while ($this->next_record()) {
	  $this->dump_record($tablename, $filter);
	};
  }

  function dump_record($tablename, $filter="") {
    $fields="";
	$values="";
    while (list($key, $val) = each($this->Record))
    if (ereg("[A-Za-z][A-Za-z0-9_]*", $key)) {
      $field_name = strtoupper($key);
	  if (!empty($val)) 
	  if (strstr( $filter, $field_name )=="") {
	    $fields.="$field_name ,";
		$val=ereg_replace("'","''",$val);
		$val=ereg_replace("\"","\\\"",$val);
		//addslashes($val);
	    $values.="'$val' ,";
	  };
    }
    $fields=substr($fields, 0, strlen($fields)-1); 
    $values=substr($values, 0, strlen($values)-1);
	$insert=sprintf("insert into %s(%s) values(%s)", $tablename, $fields, $values);
	echo "\$db->query(\"$insert\");\n";
  }
  };

  $prepend=1;
} 
  
?>

nota : all the files in the directory phlib are from
the php library (find the link on your server).

-------------------------------
listbox.inc:
-------------------------------
<%

Class Listbox {

  function show($ary, $name, $value="") {

    ## Check that we have an array...
    if (!is_array($ary))
      return;

    echo("<select name=\"$name\">");

    reset($ary);      
    while(list($key, $val) = each($ary)) {
      ## Process a single row
	  echo("<option value=\"$val\">$key</option>");
    }
    echo("</select>");
  }

  ## Walk a database query result $db and display it as
  ## a table, tagging everything with $class.

  function show_result($db, $keyname, $valname, $name, $value="") {
    $row = 0;
    echo("<select name=\"$name\">");

    //$db->seek(0);      
    while($db->next_record()) {
      ## Process a table row
	  $key=$db->f($keyname);
	  $val=$db->f($valname);
	  echo "<option ";
	  if ($value==$val) echo "selected ";
	  echo "value=\"$val\">$key</option>\n";
    }
    echo("</select>");
  }

}

%>
-------------------------------
local.inc:
-------------------------------
<?php
/*
 * Session Management for PHP3
 *
 * (C) Copyright 1998 SH Online Dienst GmbH
 *                    Boris Erdmann, Kristian Koehntopp
 *
 * $Id: local.inc,v 1.6 1998/07/15 11:07:59 kk Exp $
 *
 */ 

class Stock_Session extends Session {
  var $classname = "Stock_Session";

  var $mode           = "cookie";          ## We propagate session IDs with cookies
  //var $fallback_mode  = "get";                 ## If this doesn't work, fall back...
  var $lifetime       = 0;                 ## 0 = do session cookies, else minutes
 
  var $database_class = "DB_stock";          
  var $database_table = "SESS_ACTV"; ## and find out session data in this table.

  function SetAuth($uno) {
  $this->db->query( "UPDATE $this->database_table SET USER_NO='$uno' WHERE sid='$this->id'");
  }

  function SetField($field, $data) {
  $this->db->query( "UPDATE $this->database_table SET $field='$data' WHERE sid='$this->id'");
  }

  function gc() {
  }
}

class Stock_Challenge_Auth extends Auth {
  var $classname      = "Stock_Challenge_Auth";

  var $lifetime       =  10;

  var $database_class = "DB_stock";
  var $database_table = "USER_IDEN";

  function auth_loginform() {
    global $sess;
    global $challenge;
    global $theroot;
    global $thedoc;
    
    $challenge = md5(uniqid(""));
    $sess->register("challenge");
    
    include("$theroot/$thedoc/crloginform.ihtml");
  }
  
  function auth_validatelogin() {
    global $sess, $usercode, $password, $challenge, $response, $entree;
	//printf("user:$usercode $sctecode");
    $this->auth["uname"]=$usercode;        ## This provides access for "loginform.ihtml"
	//printf($challenge."-r-".$response."<br>");
    $this->db->query(sprintf("select * from %s where USER_CODE = '%s'",
                          $this->database_table,
                          addslashes($usercode)));

    if ($this->db->next_record()) {
      $uid    = $this->db->f("USER_ID");
      $uno    = $this->db->f("USER_NO");
	  if (!empty($this->auth["nuser"])) {
	    if ($uno!=$this->auth["nuser"]) {
	      $this->db->query("delete from CADDY where SID='$sess->id'");
		  //echo "delete from CADDY where SID='$sess->id'";
		};
	  }
      $perm   = $this->db->f("USER_PERM");
      $pass   = $this->db->f("USER_MDP");
      $nscte  = $this->db->f("SCTE_NO");
      $nclnt  = $this->db->f("CLNT_NO");
	  //printf("$nclnt");
      $this->auth["nscte"]=$nscte;
      $this->auth["nclnt"]=$nclnt;
      $this->auth["nuser"]=$uno;
      $entree = $this->db->f("USER_ENTR");
      $this->auth["uentry"]=trim($entree);
      $lang = trim($this->db->f("CODE_LANG"));
      if ($lang=="") {
        $lang="/lang_fr";
      } else {
        $lang="/lang_".strtolower($lang);
      };
      $this->auth["ulangdir"]=trim($lang);
      $this->auth["ulang"]=trim($lang);
      $this->auth["utype"]=trim($this->db->f("TYP_USER"));
      $this->auth["umarq"] = trim($this->db->f("CODE_MARQ"));
      $this->auth["urems"] = trim($this->db->f("TAUX_REMS"));
	  //$this->db->free_result();
    } else {
	  return "";
	}
	//printf("$uid $nscte ");
	//echo "$uid $perm $pass $entree";
	##echo "$response<BR>";
    ## True when JS is disabled
    if ($response == "") {
      if ($password != $pass) {
        return false;
      } else {
        $this->auth["perm"] = $perm;
        $sess->SetAuth($uno);
        return $uid;
      }
    }
    
	//echo "$expected_response<br>";
	$expected_response = md5("$usercode:$pass:$challenge");
	//printf($expected_response."-r-".$response."-".$pass."<br>");
    ## Response is set, JS is enabled
    if ($expected_response != $response) {
      return false;
    } else {
      $this->auth["perm"] = $perm;
      $sess->SetAuth($uno);
	  //printf("ok");
      return $uid;
    }
  }
}

class Stock_Perm extends Perm {
  var $classname = "Stock_Perm";
  
  var $permissions = array(
                            "user"       => 1,
                            "client"     => 3,
                            "var"     => 4,
                            "super" => 8,
                            "admin"      => 24
                          );

  function perm_invalid($does_have, $must_have) {
    global $perm, $auth, $sess;
    global $theroot;
    global $thedoc;
    $thelang =$auth->auth["ulang"];
    include("$theroot/$thedoc/$thelang/perminvalid.ihtml");
  }
}

class Stock_Caddy extends Caddy {
  var $classname      = "Stock_Caddy";

  var $database_class = "DB_stock";
  var $database_table = "CADDY";
  var $i;
  var $header;
  var $footer;
  var $rowform;

  function startCaddy($row, $head="", $foot="") {
    $nr=$this->start();
	$this->header=$head;
	$this->footer=$foot;
	$this->rowform=$row;
	return $nr;
  }

  function form_open()  {
  $this->i=0;
  echo '
    <TABLE BORDER="1">
    <TR>
        <TD > <font face="arial" size="2"><B>R?f?rence</B></font></TD>
        <TD > <font face="arial" size="2"><B>D?signation</B></font></TD>
        <TD > <font face="arial" size="2"><B>Prix</B></font></TD>
        <TD > <font face="arial" size="2"><B>Quantit&eacute;</B></font></TD>
        <TD > <font face="arial" size="2"><B>Total HT</B></font></TD>
		<TD > <font face="arial" size="2">Modifier</font></TD> 
		<TD > <font face="arial" size="2">Supprimer</font></TD> 
    </TR>
	';
    return; 
  }

  function form_close()  {
    $dtotal=number_format($this->total, 2, ",", " ");
    echo '
      <TR>
        <TD ALIGN="right" colspan="4"> <font face="arial" size="2"><B>Total Commande HT: </B></font></TD>
        <TD ALIGN="right"> <font face="arial" size="2">',$dtotal,' FRF</font></TD>
		<TD >&nbsp;</TD> 
		<TD >&nbsp;</TD> 
      </TR>
      </TABLE>
	';
    return; 
  }

  function form_item($art, $nom, $num, $prix, $cdevs)  {
    echo "<tr>";
    echo "<form method=\"get\" action=\"cmdmodif.phtml\">";
	echo "<input type=\"hidden\" name=\"mnopt\" value=\"25000\">";
    echo "<input type=\"hidden\" name=\"action\" value=\"25040\">";
    echo "<input type=\"hidden\" name=\"art\" value=\"$art\">";
    echo "<td ><font face=\"arial\" size=1>";
    echo $art;
    echo "</td>";
    echo "<td ><font face=\"arial\" size=1>";
    echo "$nom";	   
    echo "</td >";
    echo "<td ALIGN=\"right\"><font face=\"arial\" size=1>";
	$dprix=number_format($prix, 2, ",", " ");
    echo "$dprix $cdevs";
    echo "</font></td>";
    echo "<td ><font face=\"arial\" size=1>";
    echo "<input type=\"text\" name=\"pqte\" value=\"$num\" size=\"7\">";       
    echo "</font></td >";
    echo "<td ALIGN=\"right\"><font face=\"arial\" size=1>";
    $lgntotal=$num*$prix;
	$dlgntotal=number_format($lgntotal, 2, ",", " ");
    echo "$dlgntotal $cdevs";
    $this->total=$this->total+$lgntotal;
    echo "</font></td>";
    echo "<td ALIGN=\"right\">";
    //echo "<input type=\"submit\" name=\"submit2\" value=\"modifier\">";       
    echo "<input type=\"hidden\" name=\"PRDT_NO\" value=\"$this->PRDT_NO\">";
    echo "<a href=\"#\" onClick=\"document.forms[$this->i*2].submit()\"><img src=\"/funny/modifier.jpg\" width=\"32\" height=\"32\" border=\"0\"></a>"; 
    echo "</td>";
    echo "</form>";
    echo "<form method=\"get\" action=\"cmdmodif.phtml\">";
	echo "<input type=\"hidden\" name=\"mnopt\" value=\"25000\">";
    echo "<input type=\"hidden\" name=\"action\" value=\"25042\">";
    echo "<input type=\"hidden\" name=\"PRDT_NO\" value=\"$this->PRDT_NO\">";
    echo "<td ALIGN=\"right\">";
    //echo "<input type=\"submit\" name=\"submit\" value=\"supprimer\">";
    echo "<a href=\"#\" onClick=\"document.forms[$this->i*2+1].submit()\"><img src=\"/funny/supprimer.jpg\" width=\"32\" height=\"32\" border=\"0\"></a>"; 
    echo "</td>";
    echo "</form>";
    echo "</tr>";
	$this->i++;
  }

  function show_cart_open()  { 
    include "$this->header";
  }

  function show_cart_close() { 
    include "$this->footer";
  }

  function show_item($art, $nom, $num, $prix) {
    $lgntotal=$num*$prix;
    $this->total=$this->total+$lgntotal;
    include "$this->rowform";
  }
}

?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-01 16:17 UTC] jim at cvs dot php dot net
Haven't heard back, so closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC