public function updateAverageNote()
    {
        $commentTableName = $this->em->getClassMetadata($this->commentManager->getClass())->table['name'];
        $threadTableName = $this->em->getClassMetadata($this->getClass())->table['name'];

        $this->em->getConnection()->beginTransaction();
        $this->em->getConnection()->query(sprintf('UPDATE %s t SET t.average_note = 0', $threadTableName));

        $this->em->getConnection()->query(sprintf(
            'UPDATE %s t, (SELECT c.thread_id, avg(c.note) as avg_note FROM %s as c WHERE c.private <> 1 GROUP BY c.thread_id) as comments_note
            SET t.average_note = comments_note.avg_note
            WHERE t.id = comments_note.thread_id
            AND t.is_commentable <> 0', $threadTableName, $commentTableName));

        $this->em->getConnection()->commit();
    }
public function updateAverageNote()
    {
        $commentTableName = $this->em->getClassMetadata($this->commentManager->getClass())->table['name'];
        $threadTableName = $this->em->getClassMetadata($this->getClass())->table['name'];

        $this->em->getConnection()->beginTransaction();
        $this->em->getConnection()->query(sprintf('UPDATE %s t SET t.average_note = 0', $threadTableName));

        $this->em->getConnection()->query(sprintf(
            'UPDATE %s t, (SELECT c.thread_id, avg(c.note) as avg_note FROM %s as c WHERE c.private <> 1 GROUP BY c.thread_id) as comments_note
            SET t.average_note = comments_note.avg_note
            WHERE t.id = comments_note.thread_id
            AND t.is_commentable <> 0', $threadTableName, $commentTableName));

        $this->em->getConnection()->commit();
    }
public function updateAverageNote ( ) { $ commentTableName = $ this -> em -> getClassMetadata ( $ this -> commentManager -> getClass ( ) ) -> table [ 'name' ] ; $ threadTableName = $ this -> em -> getClassMetadata ( $ this -> getClass ( ) ) -> table [ 'name' ] ; $ this -> em -> getConnection ( ) -> beginTransaction ( ) ; $ this -> em -> getConnection ( ) -> query ( sprintf ( 'UPDATE %s t SET t.average_note = 0' , $ threadTableName ) ) ; $ this -> em -> getConnection ( ) -> query ( sprintf ( 'UPDATE %s t, (SELECT c.thread_id, avg(c.note) as avg_note FROM %s as c WHERE c.private <> 1 GROUP BY c.thread_id) as comments_note
            SET t.average_note = comments_note.avg_note
            WHERE t.id = comments_note.thread_id
            AND t.is_commentable <> 0' , $ threadTableName , $ commentTableName ) ) ; $ this -> em -> getConnection ( ) -> commit ( ) ; }
Updates the threads average note from comments notes.
Updates the threads average note from comments notes .