Problem with ControllerPublic

OsKaR

Member
Hi, I'm testing for customization XenForo, to see if you can lend a hand with the following code:

PHP:
class Puntos_ControllerPublic_Thread extends XFCP_Puntos_ControllerPublic_Thread
{
    public function actionAddReply()
    {
        // get parent       
        $parent = parent::actionAddReply();   
        
        // get userId
        $userId = XenForo_Visitor::getUserId();
        $points = '10';
        
        // conex db
        $db = $this->_getDb();
        
        // sumar puntos
        $db->query('UPDATE xf_user SET trophy_points = trophy_points+? WHERE user_id = ?', array($points, $userId));
        
        return $parent;
    }
}


I get error and does not update the field trophy_points.

A greeting.
 
It has been a while but at least in the older versions of XF I do believe the function _getDb() was not available in the ContrllerPublic class.
Try $db = XenForo_Application::getDb();
 
It has been a while but at least in the older versions of XF I do believe the function _getDb() was not available in the ContrllerPublic class.
Try $db = XenForo_Application::getDb();
You're correct. I will hazard a guess that the error will be Call to undefined method ...::_getDb() etc.
 
I missed that part. It still doesn't have a _getDb() function I think. All direct database touching should be done in a model, so you should be using a model for adding trophy points like that. Also probably a bad idea to add trophy points manually, since if you rebuild them you will lose the points.
 
It has been a while but at least in the older versions of XF I do believe the function _getDb() was not available in the ContrllerPublic class.
Try $db = XenForo_Application::getDb();

Thank you very much, now it works. ;)

P.S. Some wiki with all the information XenForo for programming?
 
P.S. Some wiki with all the information XenForo for programming?
Unfortunately not, but it should be very easy to get to grips with everything by searching in this forum, reading some of the user made tutorials there are and just navigating through the code. And of course you can ask questions all you want.
 
Unfortunately not, but it should be very easy to get to grips with everything by searching in this forum, reading some of the user made tutorials there are and just navigating through the code. And of course you can ask questions all you want.

Thank you, the truth is I was using vb, and returning to XenForo, there are plugins that are difficult to perform, but in about an hour and have my point system topic, answers, etc... ;)

Try not crazy with questions you again :)

P.S. Sorry for my English.
 
Top Bottom