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

Laravel 在代码中获取表结构

WBOY
Release: 2016-06-20 12:48:42
Original
1171 people have browsed it

把下列方法添加到你的 Model

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

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

欢迎加入 Laravel 交流群:365969825

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template