PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 13, 2022

[FIXED] How to maximize the row size in laravel | mysql

 April 13, 2022     database-design, laravel, migration, mysql     No comments   

Issue

I want to max the size of the row description. I already set size to 10240 but still it shows error. how to store data in this column because i have to save large amount of data

 public function up()
{
    Schema::create('final_news', function (Blueprint $table) {
        $table->id();
        $table->integer('id_newspaper');
        $table->string('heading');
        $table->string('description', 10240);
        $table->timestamps();
    });
}

ERROR I GET

 SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'description' at row 1 (SQL: insert into `final_news` (`id_newspaper`, `heading`, `d

escription, updated_at, created_at`)


Solution

if string is long you can use longtext

  $table->longText('description')

The longText method creates a LONGTEXT equivalent column:

Ref:https://laravel.com/docs/8.x/migrations#column-method-longText



Answered By - John Lobo
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing