$adapter
$adapter : \Phinx\Db\Adapter\AdapterInterface
Abstract Seed Class.
It is expected that the seeds you write extend from this class.
This abstract class proxies the various database methods to your specified adapter.
$adapter : \Phinx\Db\Adapter\AdapterInterface
$input : \think\console\Input
$output : \think\console\Output
__construct(\think\console\Input $input = null, \think\console\Output $output = null)
Class Constructor.
\think\console\Input | $input | |
\think\console\Output | $output |
run()
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
setAdapter(\Phinx\Db\Adapter\AdapterInterface $adapter) : \Phinx\Seed\MigrationInterface
Sets the database adapter.
\Phinx\Db\Adapter\AdapterInterface | $adapter | Database Adapter |
getAdapter() : \Phinx\Db\Adapter\AdapterInterface
Gets the database adapter.
setInput(\think\console\Input $input) : \Phinx\Seed\MigrationInterface
Sets the input object to be used in migration object
\think\console\Input | $input |
getInput() : \think\console\Input
Gets the input object to be used in migration object
setOutput(\think\console\Output $output) : \Phinx\Seed\MigrationInterface
Sets the output object to be used in migration object
\think\console\Output | $output |
getOutput() : \think\console\Output
Gets the output object to be used in migration object
table(string $tableName, array $options = array()) : \Phinx\Db\Table
Returns an instance of the <code>\Table</code> class.
You can use this class to create and manipulate tables.
string | $tableName | Table Name |
array | $options | Options |
<?php
use think\migration\Seeder;
class Admin 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,
'xingming' => '超级管理员1',
'username' => 'admin',
'school_id' => 1,
'password' => '$apr1$RSUodBwI$zOhVq9RQWfQDOW2sbeCDS1',
],
[
'id' => 2,
'xingming' => '超级管理员2',
'username' => 'admin1',
'school_id' => 1,
'password' => '$apr1$RSUodBwI$zOhVq9RQWfQDOW2sbeCDS1',
],
];
// 保存数据
$this->table('admin')->insert($rows)->save();
}
}