diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2011-06-24 11:56:35 -0400 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2011-06-24 11:56:35 -0400 |
commit | 89f0b963feaf2f02ce4dc222e3e77b0207fd5824 (patch) | |
tree | b40d7a946e1ebf847c6a2d12e65d794f9183a367 /lib/class/dba.class.php | |
parent | 383c21ffa981f11d534871f76126f6cf4b7f4d69 (diff) | |
download | ampache-89f0b963feaf2f02ce4dc222e3e77b0207fd5824.tar.gz ampache-89f0b963feaf2f02ce4dc222e3e77b0207fd5824.tar.bz2 ampache-89f0b963feaf2f02ce4dc222e3e77b0207fd5824.zip |
DBA changes
Make fetch_* automatically clean up result sets by default. Add a seek
function for any cases where we want to iterate over the same result set
multiple times.
Diffstat (limited to 'lib/class/dba.class.php')
-rw-r--r-- | lib/class/dba.class.php | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php index 4490067b..e63c14af 100644 --- a/lib/class/dba.class.php +++ b/lib/class/dba.class.php @@ -136,13 +136,18 @@ class Dba { /** * fetch_assoc * This emulates the mysql_fetch_assoc and takes a resource result - * we force it to always return an array, albit an empty one + * we force it to always return an array, albeit an empty one + * The optional finish parameter affects whether we automatically clean + * up the result set after the last row is read. */ - public static function fetch_assoc($resource) { + public static function fetch_assoc($resource, $finish = true) { $result = mysql_fetch_assoc($resource); if (!$result) { + if ($finish) { + self::finish($resource); + } return array(); } @@ -153,13 +158,18 @@ class Dba { /** * fetch_row * This emulates the mysql_fetch_row and takes a resource result - * we force it to always return an array, albit an empty one + * we force it to always return an array, albeit an empty one + * The optional finish parameter affects whether we automatically clean + * up the result set after the last row is read. */ - public static function fetch_row($resource) { + public static function fetch_row($resource, $finish = true) { $result = mysql_fetch_row($resource); if (!$result) { + if ($finish) { + self::finish($resource); + } return array(); } @@ -185,6 +195,14 @@ class Dba { } // num_rows /** + * seek + * This resets the row pointer to the specified position + */ + public static function seek($resource, $row) { + return mysql_data_seek($resource, $row); + } + + /** * finish * This closes a result handle and clears the memory associated with it */ |