码迷,mamicode.com
首页 > 其他好文 > 详细

laravel5.2如何创建视图表

时间:2016-07-01 13:23:57      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

例:要把mentor_infosperson_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如何创建视图表

标签:

原文地址:http://www.cnblogs.com/fgz2016/p/5632543.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!