User list with IP

Stepel

Member
Hi ,

what is the best way to get user list with their last IP ?
When i use self::FETCH_LAST_ACTIVITY and
typical query from User Model

Code:
return $this->fetchAllKeyed($this->limitQueryResults(
            '
                SELECT user.*
                    ' . $joinOptions['selectFields'] . '
                FROM xf_user AS user
                ' . $joinOptions['joinTables'] . '
                WHERE ' . $whereClause . '
                ' . $orderClause . '
            ', $limitOptions['limit'], $limitOptions['offset']
        ), 'user_id');

i get warning:
Mysqli statement execute error : The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay

xf_user table contains about 2 300 000 records..
 
What about just

PHP:
$users = XenForo_Model::create('XenForo_Model_User')->getUsers(array(), array('join' => XenForo_Model_User::FETCH_LAST_ACTIVITY);
Zend_Debug::dump($users);
 
I have sth like that:

PHP:
public function MyFunc(array $conditions, array $fetchOptions = array())
    {
        $whereClause = $this->prepareUserConditions($conditions, $fetchOptions);

        $this->addFetchOptionJoin($fetchOptions, self::FETCH_LAST_ACTIVITY);
        $orderClause = $this->prepareUserOrderOptions($fetchOptions, 'user.username');
        $joinOptions = $this->prepareUserFetchOptions($fetchOptions);
        $limitOptions = $this->prepareLimitFetchOptions($fetchOptions);

       
        return $this->fetchAllKeyed($this->limitQueryResults(
            '
                SELECT user.*
                    ' . $joinOptions['selectFields'] . '
                FROM xf_user AS user
                ' . $joinOptions['joinTables'] . '
                WHERE ' . $whereClause . '
                ' . $orderClause . '
            ', $limitOptions['limit'], $limitOptions['offset']
        ), 'user_id');
    }

I think it works like your proposition. Unfortunately it doesn't work when we have example 1000 users online. When there is example 500 users online then it works..Maybe I should just use SET SQL_BIG_SELECTS=1 and that's all..
Maybe is there any differenet way to get IP of user..?
 
Top Bottom