Laravel run error under MySQL5.1, error is as follows:
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))
But I wrote the PDO to perform the test without a problem
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();}
Data table structure:
Also on the Internet to find that the change Sql_mode also changed, still error
The problem has been solved by adding a double quote problem caused by shell filtering
Reply content:
Laravel run error under MySQL5.1, error is as follows:
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))
But I wrote the PDO to perform the test without a problem
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();}
Data table structure:
Also on the Internet to find that the change Sql_mode also changed, still error
The problem has been solved by adding a double quote problem caused by shell filtering