首页  >  文章  >  后端开发  >  laravel5.3 在 mysql5.1中运行出错 error: 1366 Incorrect integer

laravel5.3 在 mysql5.1中运行出错 error: 1366 Incorrect integer

WBOY
WBOY原创
2016-09-26 08:40:131545浏览

Laravel 在 MySQL5.1 下运行出错 ,错误如下:

<code>SQLSTATE[HY000]: General error: 1366 Incorrect integer value: ''1'' for column 'status' at row 1 (SQL: insert into `cases` (`case_name`, `status`, `updated_at`, `created_at`) values ('fdsafdsadsa', '1', 1474504956, 1474504956))
</code>

但是自己写的PDO执行测试却没有问题

<code>try {
    $sth = $db->prepare('insert into cases(case_name,status,updated_at,created_at) values (?,?,?,?)');
    $sth->bindValue(1, '我也是中文', PDO::PARAM_STR);
    $sth->bindValue(2, '1', PDO::PARAM_INT);
    $sth->bindValue(3, time(), PDO::PARAM_INT);
    $sth->bindValue(4, time(), PDO::PARAM_INT);

    $sth->execute();
} catch (\Exception $e)
{
    echo $e->getMessage();
}</code>

数据表结构:laravel5.3 在 mysql5.1中运行出错 error: 1366 Incorrect integer

也在网上查询了说是更改SQL_MODE也更改过了,依然报错

问题已解决是加了Shell过滤导致的双重引号问题

回复内容:

Laravel 在 MySQL5.1 下运行出错 ,错误如下:

<code>SQLSTATE[HY000]: General error: 1366 Incorrect integer value: ''1'' for column 'status' at row 1 (SQL: insert into `cases` (`case_name`, `status`, `updated_at`, `created_at`) values ('fdsafdsadsa', '1', 1474504956, 1474504956))
</code>

但是自己写的PDO执行测试却没有问题

<code>try {
    $sth = $db->prepare('insert into cases(case_name,status,updated_at,created_at) values (?,?,?,?)');
    $sth->bindValue(1, '我也是中文', PDO::PARAM_STR);
    $sth->bindValue(2, '1', PDO::PARAM_INT);
    $sth->bindValue(3, time(), PDO::PARAM_INT);
    $sth->bindValue(4, time(), PDO::PARAM_INT);

    $sth->execute();
} catch (\Exception $e)
{
    echo $e->getMessage();
}</code>

数据表结构:laravel5.3 在 mysql5.1中运行出错 error: 1366 Incorrect integer

也在网上查询了说是更改SQL_MODE也更改过了,依然报错

问题已解决是加了Shell过滤导致的双重引号问题

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn