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

Object of class could not be converted to string

Discussion in 'XenForo Development Discussions' started by TheBigK, Nov 6, 2015.

  1. TheBigK

    TheBigK Well-Known Member

    One of the functions in my model looks like this:

    PHP:
    public function getListOfAllAuthors()
    {
    return 
    $this->_getDb()->fetchAll('
    SELECT username AS username FROM xf_thread AS threads
    INNER JOIN EWRporta2_catlinks AS catlinks
    ON (catlinks.thread_id = threads.thread_id)
    WHERE catlinks.category_id = 1
    GROUP BY username;
    '
    );
    }
    The query itself runs fine and returns expected output when I run it directly on the database. However, XF says :-

    This is what my controller has: -

    PHP:
    $reportModel $this->_getBloggerReportModel();
    $allAuthors $this->$reportModel->getListOfAllAuthors();
    Been scratching my head over this for long. I tried replacing fetchAll with query('') but it didn't help. What am I doing wrong?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    PHP:
    $allAuthors $this->$reportModel->getListOfAllAuthors();
    Should probably be:

    PHP:
    $allAuthors $reportModel->getListOfAllAuthors();
     
    Robust, Xon and SneakyDave like this.
  3. TheBigK

    TheBigK Well-Known Member

    Oh meh! I guess I'm too much in love with this!
     

Share This Page