i'm trying to get a list of the column data types for a certain table. I have noticed eloquent has some methods that do this so i'm trying to use these.
$grammar = DB::connection()->getSchemaBuilder();
$schema = DB::select($grammar->getColumnListing('vehicles'));
However i'm getting the following error when calling getColumnListing
:
Array to string conversion
Not too sure where this so called Array
is... the method expects a String
:
vendor\\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);
}
Laravel only provides a list of column names:
Schema::getColumnListing('vehicles');
You can get more details by installing the doctrine/dbal
package:
Schema::getConnection()->getDoctrineSchemaManager()->listTableColumns('vehicles');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.