Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted October 17, 20177 yr 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? }
October 17, 20177 yr $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.
Archived
This topic is now archived and is closed to further replies.