简体   繁体   English

雄辩地获取表架构,获取数组到字符串的转换错误

[英]Get table schema using eloquent, get Array to string conversion error

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 : 但是,调用getColumnListing时出现以下错误:

Array to string conversion 数组到字符串的转换

Not too sure where this so called Array is... the method expects a String : 不太确定这个所谓的Array在哪里...该方法需要一个String

vendor\\laravel\\framework\\src\\Illuminate\\Database\\Schema\\Builder.php 供应商\\ laravel \\框架的\\ src \\照亮\\数据库\\架构\\ 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: Laravel仅提供列名称列表:

Schema::getColumnListing('vehicles');

You can get more details by installing the doctrine/dbal package: 您可以通过安装doctrine/dbal软件包来获取更多详细信息:

Schema::getConnection()->getDoctrineSchemaManager()->listTableColumns('vehicles');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在php类构造中使用数组将数组转换为字符串会出错 - use array in php class construct get Array to string conversion error laravel eloquent 数组到字符串的转换 - laravel eloquent Array to string conversion Laravel eloquent all() 方法给出错误“数组到字符串转换” - Laravel eloquent all() method gives error "Array to string conversion" Laravel Eloquent / 多对多关系给出错误(数组到字符串的转换) - Laravel Eloquent / Many to Many Relations gives error ( Array to string conversion ) 一直试图使用过程php连接到数据库,但我将错误数组转换为字符串 - Have been trying to connect to the database using procedural php but i get error array to string conversion 无法使用 ajax 从 php 文件获取 implode() 响应的值(数组到字符串转换错误) - Cannot get value of implode() response from php file using ajax (array to string conversion error) 尝试获取字段值时出现“数组到字符串转换错误” - "Array to string conversion error" when trying to get the values of fields 为什么会出现数组到字符串转换错误? - Why do I get array to string conversion error? 使用雄辩的内部雄辩查询遍历数组以获取数据 - looping through array to get data using eloquent inside eloquent query 雄辩地获取字段中具有数组值的记录 - Get records with array values in a field using eloquent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM