我正在尝试获取特定表的列数据类型的列表。我已经注意到雄辩有一些方法可以做到这一点,所以我试图使用这些方法。
$grammar = DB::connection()->getSchemaBuilder();
$schema = DB::select($grammar->getColumnListing('vehicles'));
但是,我在致电getColumnListing
时遇到以下错误:
数组到字符串的转换
不太确定这个所谓的Array
在哪里...该方法期望使用String
:
供应商\ laravel \ framework \ src \ Illuminate \ Database \ Schema \ Builder.php
/**
* Get the column listing for a given table.
*
* @param string $table
* @return array
*/
public function getColumnListing($table)
{
$table = $this->connection->getTablePrefix().$table;
$results = $this->connection->select($this->grammar->compileColumnListing($table));
return $this->connection->getPostProcessor()->processColumnListing($results);
}
答案 0 :(得分:1)
Laravel仅提供列名列表:
Schema::getColumnListing('vehicles');
您可以通过安装doctrine/dbal
软件包来获取更多详细信息:
Schema::getConnection()->getDoctrineSchemaManager()->listTableColumns('vehicles');