thinkphp Illegal Data Objects

Source: Internet
Author: User
$data = $_post;       $data [' user_id ']    = 1;       $data [' create_at ']  = Date ("y-m-d h:i:s");       $data [' update_at ']  = Date ("y-m-d h:i:s");       $data [' is_enable ']  = 1;       $data [' is_visible '] = 1;       $categoryModel  = new \admin\model\categorymodel ();       $footPosition   = $categoryModel->getfootposition ();       $data [' position ']   = intval ($footPosition) + 1;       Var_dump ($data);    $categoryModel->add ($data);

I started to think that the position type was wrong, but whether it was a string or an int, it was the same as reporting an illegal data object error. $data [' position '] = intval ($footPosition) + 1; This comment is no problem with inserting data. Help me.

Var_dump after the results are as follows, can not see what the problem ah.

Array (7) {["Category_name"]=> string (12) "Rumblings" ["user_id"]=> int (1) ["Create_at"]=> string (19) "2015-04-05 15 : 39:41 "[" Update_at "]=> string ()" 2015-04-05 15:39:41 "[" Is_enable "]=> int (1) [" is_visible "]=> int (1) [" Position "]=> int (2)}

The database field position, determined not to contain spaces, and the column names are consistent.

Reply to discussion (solution)

$footPosition = $categoryModel->getfootposition ();
And then print out $footPosition see what it is

In addition, the original error message should be given when an error occurs

The issue has been resolved. Into the Thinkphp\model,_facade function,

   foreach ($data as $key = + $val) {                file_put_contents ("Xiaobin.txt", $key. " \ n ", file_append);                File_put_contents ("Xiaobin.txt", $fields, file_append);                   if (!in_array ($key, $fields, True)) {                       if (app_debug) {                           E (L (' _data_type_invalid_ '). ': ['. $key. ' = '. $val. ');                       }                                           Unset ($data [$key]);                   } ElseIf (Is_scalar ($val)) {                       //field type check and cast                       $this->_parsetype ($data, $key);}               }

Find field array results as follows: Category_iduser_idcategory_nameblog_numcreate_atupdate_atis_enableis_visiblepre_positionnext_ Positioncategory_idarray, these are database column names, where Pre_position,next_position is the field at the beginning of the table, and then I delete the columns and add the position column. The cache is disabled, so clearing the cache is useless.
Finally found that the data saved in the Runtime/data/_fields, delete it.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.