亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過 sqlite 插入數據時 Laravel 中的 PHP 錯誤

通過 sqlite 插入數據時 Laravel 中的 PHP 錯誤

PHP
元芳怎么了 2022-10-28 14:22:47
我正在研究 Laravel 并在 php artisan 中工作,但我不斷收到此錯誤:用消息'SQLSTATE [23000]照亮/數據庫/查詢異常:完整性約束違規:19 NOT NULL約束失?。簆rofiles.url(SQL:插入“profiles”(“title”,“description”,“user_id”,“updated_at” , "created_at") 值 (Cool, Desc, 1, 2020-03-12 02:03:16, 2020-03-12 02:03:16))'我正在將配置文件附加到用戶,并且我的用戶表包含以下內容:>> User::all()=> Illuminate\Database\Eloquent\Collection {#2992     all: [       App\User {#2993         id: "1",         name: "Test User1",         email: "[email protected]",         username: "test1",         email_verified_at: null,         created_at: "2020-03-12 02:01:08",         updated_at: "2020-03-12 02:01:08",       },     ],    }這是我在 PHP Artisan 中輸入的>>> $profile = new \App\Profile();=> App\Profile {#2987}>>> $profile->title = 'Cool Title';=> "Cool Title">>> $profile->description = 'Desc';=> "Desc">>> $profile->user_id = 1;=> 1>>> $profile->save();Profiles_table.phpclass CreateProfilesTable extends Migration{    /**     * Run the migrations.     *     * @return void     */    public function up()    {        Schema::create('profiles', function (Blueprint $table) {            $table->bigIncrements('id')->nullable;            $table->unsignedBigInteger('user_id')->nullable;            $table->string('title')->nullable;            $table->text('description')->nullable;            $table->string('url')->nullable;            $table->timestamps();            $table->index('user_id');        });    }    /**     * Reverse the migrations.     *     * @return void     */    public function down()    {        Schema::dropIfExists('profiles');    }}我找不到失敗的原因。希望有人能找出是什么原因造成的。謝謝
查看完整描述

1 回答

?
慕的地10843

TA貢獻1785條經驗 獲得超8個贊

我認為您的“個人資料”遷移有誤。

$table->string('url')->nullable;

$table->string('url')->nullable();


查看完整回答
反對 回復 2022-10-28
  • 1 回答
  • 0 關注
  • 61 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號