gpt4 book ai didi

mysql - 架构 getColumnType 不起作用

转载 作者:行者123 更新时间:2023-11-29 18:11:04 24 4
gpt4 key购买 nike

尝试在我的 json(laravel 项目)中获取列类型,但不起作用?有人能看出哪里出了问题吗?

protected function getType()
{
return Schema::getColumnType($this->builder->getModel()->getTable() , $this->getUpdatableColums());
}
enter code here
protected function getRecords(Request $request)
{
// return $this->builder->limit($request->limit)->orderBy('id', 'asc')->get($this->getDisplayableColums());
return $this->builder
->limit($request->limit)
->orderBy('id', 'asc')
->get($this->getDisplayableColums())
->getType();
}

最佳答案

在 getType 方法中,您似乎传递了一个数组而不是字符串

protected function getType()
{
return Schema::getColumnType($this->builder->getModel()->getTable() , $this->getUpdatableColums());
}

laravel 5.5 文档说“string getColumnType(string $table, string $column)”

https://laravel.com/api/5.5/Illuminate/Database/Schema/Builder.html#method_getColumnType

您也许可以更改 getType 方法以获取列名称。并在代码中执行循环

foreach ($this->getUpdatableColumns() as $column) {
$this->getType($column);
}

关于mysql - 架构 getColumnType 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47402238/

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