![](/img/trans.png)
[英]Query Exception when creating a database record using laravel eloquent
[英]when migrate the table throws exception in laravel eloquent
帮我解决
[Symfony\\Component\\Debug\\Exception\\FatalThrowableError]
找不到类“Doctrine\\DBAL\\Driver\\PDOMySql\\Driver”
你需要doctrine/dbal
包吗?
如果还没有,请运行以下命令。
composer require doctrine/dbal
阅读关于修改列的部分
https://laravel.com/docs/5.6/migrations#modifying-columns
取自 Laravel 文档
在修改一个列之前,一定要在你的 composer.json 文件中添加doctrine/dbal 依赖项。 Doctrine DBAL 库用于确定列的当前状态并创建对列进行指定调整所需的 SQL 查询:
运行composer require doctrine/dbal
然后
运行composer update
。
它应该解决这个问题。
composer require doctrine/dbal:^2.12.1
他们更改了 dbal 3 上的类路径,因此您将需要旧版本。
您需要正确生成迁移,然后只有当您尝试迁移表时它才会起作用
要创建迁移,您需要使用 make:migration
php artisan make:migration create_users_table
新迁移将放置在您的 database/migrations 目录中。 每个迁移文件名都包含一个时间戳,允许 Laravel 确定迁移的顺序。
--table 和 --create 选项也可用于指示表的名称以及迁移是否将创建新表。 这些选项使用指定的表预先填充生成的迁移存根文件:
例如,
php artisan make:migration create_users_table --create=users
php artisan make:migration add_votes_to_users_table --table=users
有关在 Laravel 中迁移表的更多信息,请阅读
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.