1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel Learning

Posted at

1,安装

  • laravel new project_name
  • composer create-project laravel/laravel --prefer-dist

2,配置数据库
在app/config/database.php中配置。将host=>127.0.0.1
database=>数据库的名字
在项目根目录下php artisan migrate:make --table="table_name" CreateUserTable
在app/database/migrations/文件夹下生成相应的文件
public function up()Schema::table('table_name',function(Blueprint $table){})写入建表query。在public function down()中写入删表语句 Schema:dropIfExists("table_name")
详细语句资料http://laravel.com/docs/schema#adding-columns

table的名字和app/models/中的文件名对应 models文件夹中的model文件需要自己创建,通过相同的名字框架可以找到对应表的类,也可以在类中指定表名

添加操作model对象:

$game = new Game;
$game->name = 'Assassins Creed';
$game->description = 'Assassins VS templars.';
$game->save();

通过在model中将public $timestamps = false; 关闭自动添加时间戳的功能

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?