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

Odd DataWriter Issue

Discussion in 'XenForo Development Discussions' started by silence, Dec 29, 2014.

  1. silence

    silence Well-Known Member

    I created a simple datawriter but I'm getting this issue that I'm not sure how to solve:

    Code:
     Fatal error: Call to a member function result_metadata() on null in /home/fdsafdsafdsa/public_html/xenforo/library/Zend/Db/Statement/Mysqli.php on line 220
    Tell me if you need more info, I'm just wondering what this is.
     
  2. Nobita.Kun

    Nobita.Kun Well-Known Member

    Put more code here. It a little information so difficult to anyone want to help :)
     
    Xon likes this.
  3. Daniel Hood

    Daniel Hood Well-Known Member

    Yeah, we need the stack trace. It looks like the query returned false instead of the statement object which is really weird.
     
  4. silence

    silence Well-Known Member

    There is no stacktrace, just this:
    Fatal error: Call to a member function result_metadata() on null in xenforo/library/Zend/Db/Statement/Mysqli.php on line 220
     
  5. silence

    silence Well-Known Member

    Here is what I'm doing exactly:

    Controller:
    Code:
        public function actionSave()
        {
            $this->_assertPostOnly();
    
            $serverId = $this->_input->filterSingle('server_id', XenForo_Input::UINT);
    
            $input = $this->_input->filter(array(
                'server_host' => XenForo_Input::STRING,
                'server_port' => XenForo_Input::UINT,
                'query_port' => XenForo_Input::UINT,
                'server_password' => XenForo_Input::STRING,
                'rcon_password' => XenForo_Input::STRING,
                'server_type' => XenForo_Input::STRING,
                'active' => XenForo_Input::BOOLEAN,
                'category_id' => XenForo_Input::UINT,
                'display_order' => XenForo_Input::UINT
            ));
    
            $writer = XenForo_DataWriter::create('XenoGamers_GameServers_DataWriter_Servers');
    
            if ($serverId)
            {
                $writer->setExistingData($serverId);
            }
    
            $writer->bulkSet($input);
            $writer->save();
    
            return $this->responseRedirect(
                XenForo_ControllerResponse_Redirect::SUCCESS,
                XenForo_Link::buildAdminLink('gameservers/servers') . $this->getLastHash($serverId)
            );
        }
    DataWriter:
    Code:
        protected function _getFields()
        {
            return array(
                'xf_gs_server' => array(
                    'server_id' => array('type' => self::TYPE_UINT, 'autoIncrement' => true),
                    'server_name' => array('type' => self::TYPE_STRING, 'maxLength' => 200, 'default' => new XenForo_Phrase('unknown')),
                    'server_host' => array('type' => self::TYPE_STRING, 'maxLength' => 200),
                    'server_port' => array('type' => self::TYPE_UINT, 'default' => 0),
                    'query_port' => array('type' => self::TYPE_UINT, 'default' => 0),
                    'server_password' => array('type' => self::TYPE_STRING, 'maxLength' => 200),
                    'rcon_password' => array('type' => self::TYPE_STRING, 'maxLength' => 200),
                    'server_type' => array('type' => self::TYPE_STRING, 'maxLength' => 20),
                    'category_id' => array('type' => self::TYPE_UINT,
                        'verification'   => array('$this', '_verifyServerCategory')
                    ),
                    'active' => array('type' => self::TYPE_BOOLEAN, 'default' => true),
                    'display_order' => array('type' => self::TYPE_UINT, 'default' => 1)
                )
            );
        }
     

Share This Page