Heim  >  Artikel  >  Backend-Entwicklung  >  laravel5.3 在 mysql5.1中运行出错 error: 1366 Incorrect integer

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

WBOY
WBOYOriginal
2016-09-26 08:40:131547Durchsuche

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过滤导致的双重引号问题

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn