class Seeder

Class Seeder

TODO: Use a future DB class Currently we're using the WordPress wpdb object. In the future, would be nice to use a custom DB class.

Properties

protected string $tablename The database table name.
protected $wpdb The WordPress database object.
protected bool $runOnce This flag is used to run the seeder only once.

Methods

__construct()

Run the database seeds.

run()

Run the database seeds.

query(string $sql)

Execute any SQL statement.

int
count()

Retrun the number of rows in the table.

insert(string $sql)

Insert a row into a table.

truncate($tablename = "")

Truncate a table.

Details

at line 39
__construct()

Run the database seeds.

at line 55
abstract run()

Run the database seeds.

You have to override this method in your seeder class.

at line 62
protected query(string $sql)

Execute any SQL statement.

Parameters

string $sql The SQL statement to execute.

at line 72
protected int count()

Retrun the number of rows in the table.

Return Value

int

at line 82
protected insert(string $sql)

Insert a row into a table.

Parameters

string $sql The SQL statement.

at line 92
protected truncate($tablename = "")

Truncate a table.

Parameters

$tablename