thinkphp Illegal data Object solution

Source: Internet
Author: User
thinkphp Illegal Data Objects
$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.

------to solve the idea----------------------
$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
  • 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.