Home >Backend Development >PHP Tutorial >Laravel 在代码中获取表结构

Laravel 在代码中获取表结构

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 12:48:421216browse

把下列方法添加到你的 Model

/**  * 获取表结构  * @return array  */public function getTableColumns(){     return $this->getConnection()->getSchemaBuilder()->getColumnListing($this->getTable());}
使用
// 实例化模型$user = new User(); // 调用方法$user->getTableColumns();

原文:http://www.laravel.ren/forum/09-15-2015-laravel

欢迎加入 Laravel 交流群:365969825

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn