nrep
Well-known member
I'm trying to fetch the total number of posts, threads and members outside of XF. I've got a script that loads the XF autoloaders, I've got DB access:
I was originally fetching these stats like this, however it is an expensive DB query when running across lots of sites concurrently:
I see that there is serialized data (boardTotals) in xf_data_registry. However, I can't figure out how to easily access these figures.
Is there a way I can get the total number of posts, threads and members naively - or a MySQL query that will unserialize for me?
PHP:
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
$db = XenForo_Application::getDb();
I was originally fetching these stats like this, however it is an expensive DB query when running across lots of sites concurrently:
PHP:
$memberCount = $db->fetchRow("SELECT COUNT(*) FROM xf_user WHERE is_banned = 0 AND user_state = 'valid';");
$memberCount = $memberCount['COUNT(*)'];
I see that there is serialized data (boardTotals) in xf_data_registry. However, I can't figure out how to easily access these figures.
Is there a way I can get the total number of posts, threads and members naively - or a MySQL query that will unserialize for me?