编写类别

This commit is contained in:
巴掌 committed 2018-10-25 16:54:56 +08:00
1 parent 50c911f98a
commit 7b3d8cee54
25 files changed
+603 -98

No files matched your search

@@ -40,6 +40,7 @@ class SystemBase extends Migrator
->addColumn('description','string',['limit'=>100,'null'=>false,'comment'=>'网站说明'])
->addColumn('copyright','string',['limit'=>15,'null'=>false,'comment'=>'版权'])
->addColumn('thinks','string',['limit'=>200,'null'=>false,'comment'=>'网站感谢'])
->addColumn('danwei','string',['limit'=>80,'null'=>false,'comment'=>'使用单位'])
->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间'])
->create();
}
@@ -0,0 +1,45 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class Category extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
// 定义数据表名称
$table = $this->table('category');
// 添加当前表字段
$table
->addColumn('title','string',['limit'=>15,'null'=>false,'comment'=>'类型标题'])
->addColumn('pid','integer',['limit'=>4,'default'=>'0','null'=>false,'comment'=>'父级ID'])
->addColumn('status','boolean',['limit'=>1,'default'=>'1','null'=>false,'comment'=>'0=禁用,1=正常'])
->addColumn('paixu','integer',['limit'=>4,'default'=>'99','null'=>false,'comment'=>'排序'])
->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间'])
->addColumn('beizhu','string',['limit'=>80,'null'=>true,'comment'=>'备注'])
->addIndex(array('title'), array('unique' => true))
->create();
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
use think\migration\Seeder;
class Category extends Seeder
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* http://docs.phinx.org/en/latest/seeding.html
*/
public function run()
{
// 初始化类别
$rows= [
// 一级类别
['id'=>1,'title'=>'单位性质','pid'=>0,'paixu' =>1],
['id'=>2,'title'=>'单位级别','pid'=>0,'paixu' =>2],
// 二级类别
// 单位性质
['title'=>'幼儿园','pid'=>1,'paixu'=>1],
['title'=>'小学','pid'=>1,'paixu'=>2],
['title'=>'九年一贯','pid'=>1,'paixu'=>3],
['title'=>'初中','pid'=>1,'paixu'=>4],
['title'=>'高中','pid'=>1,'paixu'=>5],
['title'=>'中等职业技术学校','pid'=>1,'paixu'=>6],
['title'=>'科研机构(教师进修学校)','pid'=>1,'paixu'=>7],
['title'=>'教育行政部门','pid'=>1,'paixu'=>8],
['title'=>'其他教育机构','pid'=>1,'paixu'=>9],
];
// 保存数据
$this->table('category')->insert($rows)->save();
}
}
Loaded 3 of 25 files, more files were not shown because too many files have changed in this diff. Show more