$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.