laravel5.2如何创建视图表
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了laravel5.2如何创建视图表相关的知识,希望对你有一定的参考价值。
例:要把mentor_infos和person_infos表创建一个mentor_infos_view视图
1 . php artisan make:migration create_mentor_infos_view
2 . class CreateMentorInfosView extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement(‘CREATE OR REPLACE VIEW mentor_infos_view AS
select p.avatar,p.person_name,p.person_phone,p.person_email,
p.person_work_years,p.career,p.person_sex,p.person_birthday,
m.*,i.image_uri
FROM mentor_infos as m
LEFT JOIN person_infos as p ON m.user_id = p.user_id LEFT JOIN sys_images as i ON p.avatar = i.image_id‘);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop(‘mentor_infos_view‘);
}
}
3.php artisan migrate
以上是关于laravel5.2如何创建视图表的主要内容,如果未能解决你的问题,请参考以下文章