cgm225 Posted May 25, 2008 Share Posted May 25, 2008 I have the following method that returns photo entries from a MySQL database. However, even when there are multiple database entries/rows, the array only returns with one entry. I have tried to debug it, and it does not seem to be a problems with the limits or binding. Any ideas? public function findPhotos() { $query = 'SELECT id, filename, caption, date, location, album, timestamp FROM images WHERE album = ? ORDER BY filename ASC LIMIT ?, ?'; $statement = $this->connection->prepare($query); $statement->bind_param('sii', $this->albumData['id'], $this->skip, $this->numberRows); $statement->bind_result($id, $filename, $caption, $date, $location, $album, $timestamp); $statement->execute(); while($statement->fetch()) { $this->photoData = array( 'id' => $id, 'filename' => $filename, 'caption' => $caption, 'date' => $date, 'location' => $location, 'album' => $album, 'timestamp' => $timestamp ); } } Link to comment https://forums.phpfreaks.com/topic/107187-solved-prepared-statement-only-returning-first-rowentry/ Share on other sites More sharing options...
cgm225 Posted May 25, 2008 Author Share Posted May 25, 2008 Got it.. I needed.. $this->photoData[$id] = array( ); Link to comment https://forums.phpfreaks.com/topic/107187-solved-prepared-statement-only-returning-first-rowentry/#findComment-549555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.