Aetherdan Posted October 17, 2017 Share Posted October 17, 2017 I can't seem to correctly iterate through the rows of a db query. Am i doing something wrong with the below example? try { $posts = \IPS\Db::i()->select('*', 'forums_posts', array('topic_id=?', $topic))->first(); } catch( \UnderflowException $e ) { // Query failed } foreach ( $posts as $post ) { // not working? } Link to comment Share on other sites More sharing options...
CodingJungle Posted October 17, 2017 Share Posted October 17, 2017 $posts = \IPS\Db::i()->select('*', 'forums_posts', array('topic_id=?', $topic)); foreach ( $posts as $post ) { // not working? } ->first() will get you the first matching record, and will throw an exception if nothing is to be found. this way, there is no exception throw, it just wont have anything or iterator over. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.