Singleton database class : removing old query results

winter

New Member
I made a singleton database class for PHP. And i thought it was working great, but actually it isn't. Im now making a page that has 3 queries. 1 to check if an album exists,1 to check if a user owns an album, the other one gets the photos from the album.Now in my third query i populate an object, however the results of the 1st 2 queries are also in that array so im getting notices!Heres an example :\[code\]Array([0] => Array ( [id] => 2 [name] => My new album 1 [slug] => my-new-album-1 [user_id] => 1 [views] => 0 [datecreated] => 2013/03/23 16:00:43 )[1] => Array ( [id] => 3 [name] => My new album 1 [slug] => my-new-album-1 [user_id] => 1 [views] => 0 [datecreated] => 2013/03/23 23:51:58 )[2] => Array ( [id] => 2 )[3] => Array ( [id] => 117 [title] => [location_id] => [date] => 2013-03-30 00:42:26 [user_id] => 1 [album_id] => 2 )\[/code\]And this is how i do a query and return the array : \[code\]mysqli_conn::getInstance()->query($sql)->all_assoc()\[/code\]And this is the part of my database class that does the query and returns the results :\[code\]public function query( $sql ){ $starttime = $this->time_to_float(); $this->query = mysqli_query($this->connection, $sql); $endtime = $this->time_to_float(); $exectime = ($endtime - $starttime); if (!$this->query){ throw new Exception(mysqli_error($this->connection)); } else { $this->arQueryLog[] = array ( 'query' => $sql, 'exectime' => $exectime, 'affected_rows' => mysqli_affected_rows($this->connection), 'last_insert_id' => $this->lastID() ); } return $this;}public function all_assoc (){ while($result = mysqli_fetch_assoc($this->query)){ $this->result[] = $result; } return $this->result;}\[/code\]How can it is so only the last query results are in the result array?Thanks!!
 
Back
Top