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

Likes for current page

Discussion in 'XenForo Development Discussions' started by Mythotical, Jul 4, 2012.

  1. Mythotical

    Mythotical Well-Known Member

    I'm trying to pull the likes for the current page of a thread that a user is currently viewing. The code I have so far is this:

        private function getPagePosts()
    $db XenForo_Application::getDb();
    $options XenForo_Application::get('options');
                SELECT *
                FROM xf_post AS post
                LEFT JOIN xf_user AS user ON (user.user_id = post.user_id)
                    post.thread_id = ? AND
                    post.likes > 0
                ORDER BY
                    post.post_date DESC
    , array( $this->_params['thread']['thread_id'] ));
    I'm doing this in a ViewPublic file for Thread.php

  2. Mythotical

    Mythotical Well-Known Member

    Wow, 19 views, minus my 3, so 16 views total and not one response.
  3. Mythotical

    Mythotical Well-Known Member

    Attempting to use:
    Returns an array, so put it in an array() it comes back with an error: An exception occurred: Mysqli prepare error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 5 OFFSET 1'

    So not sure where to go now.
  4. Mythotical

    Mythotical Well-Known Member

    Ok so I have it working, the problem now is that it displays results for page-2 instead of the current page. How do I get this to work with showing me current page results only?

Share This Page