首页 > 其他 > 详细

使用laravel 的artisan快速创建表

时间:2015-11-01 12:38:15      阅读:588      评论:0      收藏:0      [点我收藏+]

参考:使用laravel 的artisan快速创建表

字段类型参考链接: 结构生成器

版本: Laravel 4.2

1. 创建migrate 文件

php artisan migrate:make create_lang_table

2. 编辑migrate文件

<?php

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

class CreateLangTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //
        Schema::create(‘lang‘, function(Blueprint $table)
        {
            $table->increments(‘id‘);//主键自增
            $table->string(‘local‘,50); //语言
            $table->string(‘title‘,30); //标题
            $table->tinyInteger(‘main‘)->nullable(); //主要语言
            $table->tinyInteger(‘published‘)->default(1); //发布
            $table->integer(‘ordering‘)->default(0); //排序
            $table->timestamps();
        });
    }

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

}

3. 创建表

1 php artisan migrate

就会看到类似的信息:

1 vagrant@precise32:/var/www/html$ php artisan migrate
2 **************************************
3 *     Application In Production!     *
4 **************************************
5 
6 Do you really wish to run this command? yes
7 Migrated: 2015_11_01_114540_create_lang_table

 

使用laravel 的artisan快速创建表

原文:http://www.cnblogs.com/fsong/p/4927439.html

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