首页 > 其他 > 详细

使用laravel 的artisan快速创建表

时间:2015-07-12 12:56:40      阅读:1221      评论:0      收藏:0      [点我收藏+]

创建migrate 文件


php artisan make:migration create_comments_table

编辑表字段


<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCommentTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
        Schema::create(‘comment‘,function(Blueprint $table){
            $table->engine = ‘InnoDB‘;
            $table->increments(‘id‘);
            $table->integer(‘news_id‘);
            $table->string(‘author_name‘);
            $table->string(‘author_url‘);
            $table->string(‘author_key‘);
            $table->string(‘ip‘);
            $table->string(‘message‘);
            $table->string(‘mail‘);
            $table->integer(‘create_time‘);
            $table->integer(‘parent_id‘);
        });
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		//
	}

}

创建表

php artisan migrate





使用laravel 的artisan快速创建表

原文:http://my.oschina.net/freax/blog/477521

(0)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!