Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Randy Calvert Posted February 23, 2022 Posted February 23, 2022 I'm trying to query the IPB DB to return an exact number of posts in the posts table. I'm using the following KB article to get me started: What I've boiled it down to was something basic like: $select = \IPS\Db::i()->select( '*', 'forums_posts', '', 'pid', '' ); $results = count( $select ); print $results; Given that I don't want to limit the number of results, I was trying to leave the limit field blank. However when I do that, the change never saves and the ACP page just returns a blank white page. I tried making the value something bigger than my current post count, but because I have almost 2M posts, IPB errors out. It apparently does not like limits higher than like 100,000. I assume I'm missing something super basic here. If someone could point me in the right direction, you'll save me a bunch of head scratching. Thanks!
Ryan Ashbrook Posted February 23, 2022 Posted February 23, 2022 $count = \IPS\Db::i()->select( 'count(*)', 'forums_posts' )->first(); print $count;
Daniel F Posted February 23, 2022 Posted February 23, 2022 You’ll need https://dev.mysql.com/doc/refman/8.0/en/counting-rows.html instead of fetching all the posts;) \IPS\Db::i()->select( 'count(*)', 'forums_posts' )->first();
Randy Calvert Posted February 23, 2022 Author Posted February 23, 2022 (edited) Thank you both very much!! I assumed it was something easy. Your help is greatly appreciated! Edited February 23, 2022 by Randy Calvert
Recommended Posts