Getting current threadid to insert into db

Mikey

Well-known member
I have a add on which I am building, which inserts threads into the database with a short (user defined) description, and I'll figure out how to display them later.

Anyway, I need a way to insert the threadid into the database into my table.

I've tried;

PHP:
public function actionAddYes() {
        $db = XenForo_Application::get('db');
        $visitor = XenForo_Visitor::getInstance();
        $userid = $visitor['user_id'];
        $blurb = $this->_input->cleanString($_POST['blurb']);
        // $date = XenForo_Application::get('time'); <- not working - if anyone could suggest an alternate, i'd appreciate that also
        $threadid = $this->get('thread_id');
        $db->query("INSERT INTO `xf_Mikey` (`threadid`, `userid`, `date`, `blurb`) VALUES ('$threadid', '$userid', '$date' '$blurb');");
		return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS);
    }

Note, what I know I've learnt from reading the development forums or through reading other people's code.

Anyway, that doesnt work, I get this: Fatal error: Call to undefined method Mikey_ControllerPublic_Index::get() in /var/www/sites/xenforo/library/Mikey/ControllerPublic/Index.php on line 33

Any help will be appreciated :)
 
Well, first of get() is a member of the DataWriter class, so you won't be able to call it via $this-> in a controller. And secondly, I'm a bit confused. Are you attempting to create a thread based on what they posted? If you are doing this when you do a thread (via the DataWriter of course) you could use getMergedData() from the DataWriter class to return an array that would have the thread_id in it. It is extremely late... and I'm working on a very small amount of sleep, so I may be off.
 
thanks kingkovifor and cezz, with their help i managed to figure it out, it was a bunch of problems, basically I wasnt doing much right :P
 
Top Bottom