簡體   English   中英

雄辯地獲取表架構,獲取數組到字符串的轉換錯誤

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

我正在嘗試獲取特定表的列數據類型的列表。 我已經注意到雄辯有一些方法可以做到這一點,所以我試圖使用這些方法。

$grammar = DB::connection()->getSchemaBuilder();
$schema = DB::select($grammar->getColumnListing('vehicles'));

但是,調用getColumnListing時出現以下錯誤:

數組到字符串的轉換

不太確定這個所謂的Array在哪里...該方法需要一個String

供應商\\ 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僅提供列名稱列表:

Schema::getColumnListing('vehicles');

您可以通過安裝doctrine/dbal軟件包來獲取更多詳細信息:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM