laravel5.3 runs error in mysql5.1 error: 1366 Incorrect integer

WBOY
Release: 2016-09-26 08:40:13
Original
1547 people have browsed it

Laravel has an error when running under MySQL5.1. The error is as follows:

<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>
Copy after login
Copy after login

But the PDO I wrote has no problem executing the test

<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>
Copy after login
Copy after login

Data table structure:laravel5.3 runs error in mysql5.1 error: 1366 Incorrect integer

I also checked online and it said that I changed SQL_MODE and changed it, but still got the error

The problem has been solved. It was the double quotation mark issue caused by adding Shell filter

Reply content:

Laravel has an error when running under MySQL5.1. The error is as follows:

<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>
Copy after login
Copy after login

But the PDO I wrote has no problem executing the test

<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>
Copy after login
Copy after login

Data table structure:laravel5.3 runs error in mysql5.1 error: 1366 Incorrect integer

I also checked online and it said that I changed SQL_MODE and changed it, but still got the error

The problem has been solved. It was the double quotation mark issue caused by adding Shell filter

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!