Re: Freeing results in DB class after returning value

From: Date: Sat, 02 Mar 2002 00:35:13 +0000
Subject: Re: Freeing results in DB class after returning value
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-926@lists.php.net to get a copy of this message
On Fri, 2002-03-01 at 20:17, Ron Dyck wrote: > Can I free the result of a query after I do a 'return' in a function. See below for > example. > > function getFileName($field, $id, $type) { > global $db; > $Query = "SELECT Name FROM image "; > $Query .= "WHERE ID = '$id' "; > $Query .= "AND Field = '$field' "; > $Query .= "AND Type = '$type' "; > return $db->getOne($Query); > $db->free(); // Not entirely sure this'll work > } getOne() does free() for you, ease of coding is the idea behind the get* methods. The only cases where you need to do free is when you do a select or some other query returning rows of data with query() or simpleQuery(). If you use query(), you must free via $result->free(), with simpleQuery() you must free via $db->freeResult($result). - Stig

« previous php.pear.general (#926) next »