laravel5.3 在 mysql5.1中執行出錯 error: 1366 Incorrect integer

WBOY
發布: 2016-09-26 08:40:13
原創
1547 人瀏覽過

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過濾導致的雙重引號問題

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!