Maison  >  Article  >  développement back-end  >  laravel5.3 在 mysql5.1中运行出错 error: 1366 Incorrect integer

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

WBOY
WBOYoriginal
2016-09-26 08:40:131547parcourir

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

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn