例:要把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
时间: 2024-11-08 23:08:32