1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

User list with IP

Discussion in 'XenForo Development Discussions' started by Stepel, Jun 27, 2015.

  1. Stepel

    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

    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..
  2. Daniel Hood

    Daniel Hood Well-Known Member

    What about just

    $users XenForo_Model::create('XenForo_Model_User')->getUsers(array(), array('join' => XenForo_Model_User::FETCH_LAST_ACTIVITY);
  3. Stepel

    Stepel Member

    I have sth like that:

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

    $orderClause $this->prepareUserOrderOptions($fetchOptions'user.username');
    $joinOptions $this->prepareUserFetchOptions($fetchOptions);
    $limitOptions $this->prepareLimitFetchOptions($fetchOptions);

                    SELECT user.*
    $joinOptions['selectFields'] . '
                    FROM xf_user AS user
    $joinOptions['joinTables'] . '
                    WHERE ' 
    $whereClause '
    $orderClause '
    $limitOptions['limit'], $limitOptions['offset']
    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..?

Share This Page