Help DataWriter Erreur When deleting

remiff

New member
Hello,
How to fix the following error
When deleting


Code:
_getExistingData returned an array but did not include data for the primary table

     XenForo_DataWriter-> setExistingData () in ThemesCorp / SiteReviews / ControllerPublic / Reviews.php at line 112
     ThemesCorp_SiteReviews_ControllerPublic_Reviews-> actionDelete () in XenForo / FrontController.php at line 351
     XenForo_FrontController-> dispatch () in XenForo / FrontController.php at line 134
     XenForo_FrontController-> run () in C: /wamp64/www/DevXenForo/index.php at line 13


Code Controller :

PHP:
            $dw = XenForo_DataWriter::create('ThemesCorp_SiteReviews_DataWriter_Reviews', XenForo_DataWriter::ERROR_EXCEPTION);
            $dw->setExistingData($reviews_id);
            $dw->delete();

Code DataWriter :

PHP:
 protected function _getFields()
    {
        return array(
          'tc_sitereviews' => array(

              'reviews_id' => array('type' => self::TYPE_UINT,     'autoIncrement' => true),
              'reviews_title' => array('type' => self::TYPE_STRING, 'required' => true),
              'reviews_content' => array('type' => self::TYPE_STRING, 'required' => true),
              'user_id' => array('type' => self::TYPE_INT),
              'dates_posted' => array('type' => self::TYPE_INT, 'required' => true, 'default' => XenForo_Application::$time),
              'rating' => array('type' => self::TYPE_INT, 'required' => true),
              'rating_avg' => array('type' => self::TYPE_INT, 'default' => '1')
          )
        );
    }

    protected function _getExistingData($data)
    {
        if (!$id = $this->_getExistingPrimaryKey($data, 'reviews_id'))
        {
            return false;
        }

        return array('reviews_id' => $this->getModelFromCache('ThemesCorp_SiteReviews_Model_Reviews')->getExistingReviews($id));
    }

    protected function _getUpdateCondition($tableName)
    {
        return 'reviews_id = ' . $this->_db->quote($this->getExisting('reviews_id'));
    }
 
As the error say, the parameter you send into the DataWriter (setExistingData()) doesn't include the primary column of the table "reviews_id".

Or the Model return an incorrect match with your response.
 
As the error say, the parameter you send into the DataWriter (setExistingData()) doesn't include the primary column of the table "reviews_id".

Or the Model return an incorrect match with your response.



Problem corrected: I change reviews_id by tc_site reviews
 
Top Bottom