Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skoobi's avatar
Level 13

General error: 1366 Incorrect integer value: '' for column

Hi.

Im transferring a database over so i can set it up with relationships etc on laravel and im coming across the error General error: 1366 Incorrect integer value: '' for column 'name1_verified' at row 1

I know its due to trying to save from a string to a bool but how can i make change it from string to boolean.

As it is now i have a name1_verified on both databases but it only has either 1 or 0 in on the old db. I want it to be a boolean on the new db, so in the migrations ive set it to boolean.

If i change the type in the new db to string then it just doesn't save it at all!

Console/MigrateAll.php

public function handle(){

        $users = User::all();

        $bar = $this->output->createProgressBar(count($users));
        $this->line("\nMigrating Verified Users::");

        foreach ($users as $user) {

            $old_user = OldUsers::where('mailbox_id', $user->mailbox_id)->first();
            $old_mailbox = OldMailbox::where('mailbox_id', $user->mailbox_id)->first();
            $customer = VerifiedUser::where('user_id', $user->id)->first();

            if(!$customer){

                User::where('mailbox_id', $user->mailbox_id)->update(['name' => $old_mailbox['name1']]);

                $verified_user = new VerifiedUser();
                $verified_user->user_id = $user['id'];

                $verified_user->name1 = $old_mailbox['name1'];
                $verified_user->name1_verified = $old_mailbox['name1_verified'];
                $verified_user->name1_verified = $old_mailbox['name1_verified_date'];

                $verified_user->name2 = $old_mailbox['name2'];
                $verified_user->name2_verified = $old_mailbox['name2_verified'];
                $verified_user->name2_verified = $old_mailbox['name2_verified_date'];

                $verified_user->name3 = $old_mailbox['name3'];
                $verified_user->name3_verified = $old_mailbox['name3_verified'];
                $verified_user->name3_verified = $old_mailbox['name3_verified_date'];

                $verified_user->name4 = $old_mailbox['name4'];
                $verified_user->name4_verified = $old_mailbox['name4_verified'];
                $verified_user->name4_verified = $old_mailbox['name4_verified_date'];

                $verified_user->name5 = $old_mailbox['name5'];
                $verified_user->name5_verified = $old_mailbox['name5_verified'];
                $verified_user->name5_verified = $old_mailbox['name5_verified_date'];

                $verified_user->verified_postcode = $old_mailbox['verified_postcode'];

                $verified_user->save();
                $bar->advance();

            }

        };

        $bar->finish();
        $this->info("  Complete... \n");
    }
0 likes
7 replies
Tray2's avatar

I would use the same structure in the new database then alter it or alter the old one first then export. Doing it on the fly is not the first option I'd choose.

skoobi's avatar
Level 13

Ah ok. I tried that but it just nulls that column for some reason. Ill give it another try.

Cheers

Tray2's avatar

And it's not wrong to use integers to determine if the user is validated or not. Some databases doesn't even have a boolean as a datatype in the database. There we have to use either number(1) or varchar(1) and set the values to 0/1 ans 'Y'/'N'.

skoobi's avatar
Level 13

Ye on the database in migration its set to boolean but it sets it to integer(1) in mysql. I thought as all the values were "1" it would just add it to the column without any fuss

skoobi's avatar
Level 13

Ok im not quite sure whats wrong here but no matter what i set the column to i get the error.

The columns are identical and still not saving to the database. Getting the same error.

If i call the values i.e.

$this->line($old_mailbox['name1_verified']); 

Theres no problem getting the values just saving. It goes through the same process on other parts of the migration and i just cant figure out why this is different

36864's avatar
36864
Best Answer
Level 13
$verified_user->name1_verified = $old_mailbox['name1_verified'];
$verified_user->name1_verified = $old_mailbox['name1_verified_date'];

Why are you setting the same property twice?

1 like
skoobi's avatar
Level 13

Oh you are a legend. I ctrl+z back a fair few steps and must have gone back to far.

Thank you for that.

Please or to participate in this conversation.