RunSql
extends Step
in package
Class RunSql
Table of Contents
- TABLE_PREFIX_PLACEHOLDER = '{WC_BLUEPRINT_TABLE_PREFIX}'
- Placeholder for the database table prefix.
- $meta_values : array<string|int, mixed>
- Meta values for the step.
- $name : string
- Name of the sql file.
- $sql : string
- Sql code to run.
- __construct() : mixed
- Constructor.
- from_table_row() : self
- Build a RunSql step for a database row, using the portable table-prefix placeholder in place of the live database prefix.
- get_json_array() : mixed
- Get the JSON array for the step.
- get_schema() : array<string|int, mixed>
- Returns the schema for the JSON representation of this step.
- get_step_name() : string
- Returns the name of this step.
- prepare_json_array() : array<string|int, mixed>
- Prepares an associative array for JSON encoding.
- set_meta_values() : void
- Set meta values for the step.
Constants
TABLE_PREFIX_PLACEHOLDER
Placeholder for the database table prefix.
public
string
TABLE_PREFIX_PLACEHOLDER
= '{WC_BLUEPRINT_TABLE_PREFIX}'
Exported SQL uses this placeholder in place of the source site's table prefix. When the Blueprint is imported, the placeholder is replaced with the importing site's prefix, so Blueprints remain portable across sites that use different database table prefixes.
Properties
$meta_values
Meta values for the step.
protected
array<string|int, mixed>
$meta_values
= array()
$name
Name of the sql file.
protected
string
$name
= 'schema.sql'
$sql
Sql code to run.
protected
string
$sql
= ''
Methods
__construct()
Constructor.
public
__construct(string $sql[, string $name = 'schema.sql' ]) : mixed
Parameters
- $sql : string
-
Sql code to run.
- $name : string = 'schema.sql'
-
Name of the sql file.
Return values
mixed —from_table_row()
Build a RunSql step for a database row, using the portable table-prefix placeholder in place of the live database prefix.
public
static from_table_row(array<string|int, mixed> $row, string $table[, string $type = 'replace into' ]) : self
Pass the unprefixed table name (e.g. 'woocommerce_shipping_zones'). The placeholder is prepended for you, so exported SQL stays portable across sites with different table prefixes. On import, ImportRunSql resolves the placeholder back to the importing site's prefix.
Parameters
- $row : array<string|int, mixed>
-
Row data keyed by column name.
- $table : string
-
Unprefixed table name.
- $type : string = 'replace into'
-
One of insert, insert ignore, replace into.
Return values
self —get_json_array()
Get the JSON array for the step.
public
get_json_array() : mixed
Return values
mixed —get_schema()
Returns the schema for the JSON representation of this step.
public
static get_schema([int $version = 1 ]) : array<string|int, mixed>
Parameters
- $version : int = 1
-
The version of the schema to return.
Return values
array<string|int, mixed> — The schema array.get_step_name()
Returns the name of this step.
public
static get_step_name() : string
Return values
string — The step name.prepare_json_array()
Prepares an associative array for JSON encoding.
public
prepare_json_array() : array<string|int, mixed>
Return values
array<string|int, mixed> — Array of data to be encoded as JSON.set_meta_values()
Set meta values for the step.
public
set_meta_values(array<string|int, mixed> $meta_values) : void
Parameters
- $meta_values : array<string|int, mixed>
-
The meta values.
