|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-04-28 04:01 UTC] arnaud@php.net
[2003-05-04 12:16 UTC] lsmith@php.net
[2003-06-11 12:10 UTC] cox@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 23:00:01 2025 UTC |
$result=$this->db->query($sql,$values); makes use of "prepare" internally and doesn't free the results. e.g., the following script, does one query 5 times and annother time with different values, yet when done, diagnose() prints out that 6 lots of prepare_tokens, prepare_types, prepare_queries were stored in the db object! I reckon at least they should have been destroyed when the results were destroyed (if no results, then right away!). <?php include_once("DB.php"); $_db=array( 'phptype' => "pgsql", 'hostspec' => "localhost", 'database' => "*****", 'username' => "*******", 'protocol' => "unix", 'password' => "***********"); $db=DB::connect($_db); if (DB::isError($db)) { die("Can't connect"); } $sql="select ?"; QUERY($db,$sql,array(1)); QUERY($db,$sql,array(1)); QUERY($db,$sql,array(1)); QUERY($db,$sql,array(1)); QUERY($db,$sql,array(1)); QUERY($db,$sql,array(2)); var_dump($db); diagnose($db); function diagnose(&$db) { foreach($db as $key=>$val) if (eregi('^prepare',$key) && is_array($val)) { print count($val). " of $key\n"; } } function QUERY(&$db,$sql,$array) { $result=$db->query($sql,array(1)); if (DB::isError($result)) { die ("Dead: ".$result->userinfo); } $numRows=$result->numRows(); if ($numRows>1) die ("Too many matches for $query,"); if ($numRows) { $data=$result->fetchRow(DB_FETCHMODE_ASSOC); } if (is_object($result)) $result->free(); return $data; } ?>