繁体   English   中英

如何将 null 值从 php 变量插入到 mysql

[英]How to insert a null value from php variable to mysql

我想通过 php 变量将字段设置为 null 值。 我正在使用 Laravel eloquent。

             if($request->sectionId=='NULL'){
               $sectionId=NULL;
             }else{
                $sectionId=$request->sectionId;
             }
            $question= new Question;
            $question->sectionid=$sectionId;

它返回给我错误:integer 值不正确:farsifor_m 列的“ farsifor_m ”。 questions 第 1 行的sectionid (SQL:插入questionsformidquestionTypeordersectionidupdated_atcreated_at )值(?、shortAnswer、1、NUll、2021-05-08 18:51:24、2021-05-08 18 :51:24))”

看来您在$request->sectionId的值中有拼写错误 - 'NUll' 而不是 'NULL'。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM