gpt4 book ai didi

php - 获取错误 [Doctrine\DBAL\DBALException] 请求未知的数据库类型点,Doctrine\DBAL\Platforms\MySQL57Platform 可能不支持它

转载 作者:行者123 更新时间:2023-12-02 05:16:20 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Laravel model with POINT/POLYGON etc. using DB::raw expressions

(3 个回答)


1年前关闭。




我正在使用 laravel我刚刚添加了一个新的迁移来增加列大小。
第一个生成的表有一个名为 latlong 的列类型 Point .
我不能修改任何列大小?

当我尝试这样做时,会出现以下错误。任何人都可以帮我解决这个问题吗?

[Doctrine\DBAL\DBALException]
Unknown database type point requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.



这是我的迁移文件。

第一次迁移用于创建表 abc
public function up()
{
Schema::create('abc', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name', 20);
$table->string('last_name', 20);
$table->string('street', 100);
$table->string('city', 50)->nullable();
$table->string('state', 50)->nullable();
$table->string('postal_code', 15);
$table->string('mobile', 10)->nullable();
$table->timestamps();
$table->softDeletes();
});
Illuminate\Support\Facades\DB::statement('ALTER TABLE abc ADD latlong POINT');

}

第二次迁移用于更新列大小
public function up()
{
Schema::table('abc', function (Blueprint $table){
$table->string('mobile', 20)->nullable()->change();
});
}

最佳答案

解决方案就像@AnhDam 建议的那样。但是您永远不应该更改 composer.json 的 vendor 目录中的文件。 Insead,在您的迁移中,添加以下函数:

public function __construct()
{
\Illuminate\Support\Facades\DB::getDoctrineSchemaManager()
->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'string');
}

关于php - 获取错误 [Doctrine\DBAL\DBALException] 请求未知的数据库类型点,Doctrine\DBAL\Platforms\MySQL57Platform 可能不支持它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47484676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com