final class MySqlProvider
    extends Base
Public API: explicitly declared with @visibility public.

Faker Provider for generating syntactically valid MySQL SQL statements.

This provider uses MySQL's official Bison grammar (sql_yacc.yy) to generate SQL that is syntactically valid. Note that generated SQL may not be semantically valid (tables/columns may not exist).

Supported MySQL versions:

    • mysql-5.6.51
    • mysql-5.7.44
    • mysql-8.0.44
    • mysql-8.1.0
    • mysql-8.2.0
    • mysql-8.3.0
    • mysql-8.4.7 (default)
    • mysql-9.0.1
    • mysql-9.1.0

maxDepth selects shortest productions once the depth is reached; it is not a SQL length limit. The basic pipeline resolves lexical spaces without inserting comments. Optional clauses may be empty. Seed the supplied Faker generator to reproduce a run within the same package version.

Register the provider with Fakerdoctest
$faker = \Faker\Factory::create();
    $faker->addProvider(new \SqlFaker\MySqlProvider($faker));
    $faker->integerLiteral(min: 42, max: 42) // => '42'

Methods§

public function __construct(
    Generator $generator,
    string|null $version = null,
    ?GrammarCoverage $coverage = null,
)
Public API: explicitly declared with @visibility public.

Register SQL formatters on the supplied Faker generator.

Parameters

$generatorGeneratorFaker generator
$versionstring|nullMySQL version tag (e.g., "mysql-8.4.7"). Null for default.
$coverage?GrammarCoverage
Choose a supported database versiondoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker, 'mysql-5.7.44');
    $provider->integerLiteral(min: 42, max: 42) // => '42'
Reject an unsupported database versiondoctest
new \SqlFaker\MySqlProvider(\Faker\Factory::create(), 'missing-version') // throws \RuntimeException: Unsupported
Calls 5
public function planner(): PlanBuilder
Public API: explicitly declared with @visibility public.

Prepares grammar analysis for constructing concrete generation plans.

Compile input before generating SQLdoctest
$provider = new \SqlFaker\MySqlProvider(\Faker\Factory::create());
    $plan = (new \SqlFaker\Generation\Choice\BytePlanCompiler())->compile('', $provider->planner());
    $provider->generate($plan) === $provider->generate($plan) // => true
Test cases 2
Calls 1
public function generate<TRequiresNonEmpty of bool>(GenerationPlan<TRequiresNonEmpty> $plan): (TRequiresNonEmpty is true ? non-empty-string : string)
Public API: explicitly declared with @visibility public.

Generates through the same engine used by the convenience methods.

Parameters

$planGenerationPlan<TRequiresNonEmpty>

Returns

(TRequiresNonEmpty is true ? non-empty-string : string)

Throws

GenerationException When derivation fails
LexicalException When lexical realization fails
Generate a statement from deterministic choice bytesdoctest
$provider = new \SqlFaker\SqliteProvider(\Faker\Factory::create());
    $plan = \SqlFaker\Generation\Plan\GenerationPlan::all()->requiringNonEmpty()->withExpansionBudget(100);
    $provider->generate($plan) !== '' // => true
Test cases 2
Called from 57
Calls 1
public function sql(StatementType|null $startRule = null, int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a syntactically valid SQL statement.

Parameters

$startRuleStatementType|nullStart rule (null for default)
$maxDepthint

Returns

string
Select a statement type explicitlydoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->sql(\SqlFaker\MySql\StatementType::Select, maxDepth: 0);
    preg_match('/\bSELECT\b/i', $sql) // => 1
Test cases 8
Calls 2
public function sqlWithoutEmptyRows(
    ?StatementType $startRule = null,
    int $maxDepth = PHP_INT_MAX,
): string
Public API: explicitly declared with @visibility public.

Generate SQL while requiring every MySQL row-value production to be non-empty.

Parameters

$startRule?StatementType
$maxDepthint

Returns

string
Select a statement type explicitlydoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->sqlWithoutEmptyRows(\SqlFaker\MySql\StatementType::Select, maxDepth: 0);
    preg_match('/\bSELECT\b/i', $sql) // => 1
Test cases 2
Calls 2
public function selectStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a SELECT statement.

Parameters

$maxDepthint

Returns

string
Generate select statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->selectStatement(maxDepth: 0);
    preg_match('/\bSELECT\b/is', $sql) // => 1
Test cases 3
Calls 3
public function insertStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate an INSERT statement.

Parameters

$maxDepthint

Returns

string
Generate insert statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->insertStatement(maxDepth: 0);
    preg_match('/\bINSERT\b/is', $sql) // => 1
Test cases 1
Calls 3
public function updateStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate an UPDATE statement.

Parameters

$maxDepthint

Returns

string
Generate update statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->updateStatement(maxDepth: 0);
    preg_match('/\bUPDATE\b/is', $sql) // => 1
Test cases 1
Calls 3
public function deleteStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a DELETE statement.

Parameters

$maxDepthint

Returns

string
Generate delete statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->deleteStatement(maxDepth: 0);
    preg_match('/\bDELETE\b/is', $sql) // => 1
Test cases 1
Calls 3
public function loadDataStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a LOAD DATA statement from MySQL's official load_stmt rule.

Parameters

$maxDepthint

Returns

string
Generate load data statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->loadDataStatement(maxDepth: 0);
    preg_match('/\bLOAD\b.*\bDATA\b.*\bINFILE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function multiTableUpdateStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a two-target UPDATE statement.

Parameters

$maxDepthint

Returns

string
Generate multi table update statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->multiTableUpdateStatement(maxDepth: 0);
    preg_match('/\bUPDATE\b.*,.*\bSET\b/is', $sql) // => 1
Test cases 1
Calls 2
public function multiTableDeleteStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a two-target DELETE statement.

Parameters

$maxDepthint

Returns

string
Generate multi table delete statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->multiTableDeleteStatement(maxDepth: 0);
    preg_match('/\bDELETE\b.*,.*\bFROM\b/is', $sql) // => 1
Test cases 1
Calls 2
public function createTableStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a CREATE TABLE statement.

Parameters

$maxDepthint

Returns

string
Generate create table statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->createTableStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bTABLE\b/is', $sql) // => 1
Test cases 1
Calls 3
public function alterTableStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate an ALTER TABLE statement.

Parameters

$maxDepthint

Returns

string
Generate alter table statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->alterTableStatement(maxDepth: 0);
    preg_match('/\bALTER\b.*\bTABLE\b/is', $sql) // => 1
Test cases 1
Calls 3
public function dropTableStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a DROP TABLE statement.

Parameters

$maxDepthint

Returns

string
Generate drop table statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->dropTableStatement(maxDepth: 0);
    preg_match('/\bDROP\b.*\bTABLE\b/is', $sql) // => 1
Test cases 1
Calls 3
public function simpleStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate any simple statement (SELECT, INSERT, UPDATE, DELETE, etc.).

This is the most general method and can produce any type of SQL statement that MySQL supports.

Parameters

$maxDepthint

Returns

string
Generate simple statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->simpleStatement(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 3
public function identifier(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a MySQL identifier via grammar derivation.

Parameters

$maxDepthint

Returns

string
Generate identifier at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->identifier(maxDepth: 0);
    $sql !== '' // => true
Test cases 2
Calls 2
public function quotedIdentifier(int $minLength = 1, int $maxLength = 64): string
Public API: explicitly declared with @visibility public.

Generate a backtick-quoted MySQL identifier.

Parameters

$minLengthint
$maxLengthint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->quotedIdentifier(minLength: 4, maxLength: 4);
    preg_match('/^`[a-z_][a-z0-9_]{3}`$/', $token) // => 1
Test cases 3
Calls 2
public function stringLiteral(int $minLength = 1, int $maxLength = 255): string
Public API: explicitly declared with @visibility public.

Generate a MySQL string literal.

Parameters

$minLengthint
$maxLengthint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->stringLiteral(minLength: 4, maxLength: 4);
    preg_match('/^\'[A-Za-z0-9_]{4}\'$/', $token) // => 1
Test cases 4
Calls 2
public function nationalStringLiteral(int $minLength = 1, int $maxLength = 255): string
Public API: explicitly declared with @visibility public.

Generate a MySQL national string literal (N'...').

Parameters

$minLengthint
$maxLengthint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->nationalStringLiteral(minLength: 4, maxLength: 4);
    preg_match('/^N\'[A-Za-z0-9_]{4}\'$/', $token) // => 1
Test cases 3
Calls 2
public function dollarQuotedString(int $minLength = 1, int $maxLength = 255): string
Public API: explicitly declared with @visibility public.

Generate a MySQL dollar-quoted string ($$...$$).

Parameters

$minLengthint
$maxLengthint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->dollarQuotedString(minLength: 4, maxLength: 4);
    preg_match('/^\$\$[A-Za-z0-9_]{4}\$\$$/', $token) // => 1
Test cases 3
Calls 2
public function integerLiteral(int $min = 1, int $max = 2147483647): string
Public API: explicitly declared with @visibility public.

Generate a MySQL integer literal.

Parameters

$minint
$maxint

Returns

string
Fix both bounds to obtain one valuedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $provider->integerLiteral(min: 42, max: 42) // => '42'
Test cases 3
Calls 2
public function longIntegerLiteral(int $min = 0, int $max = 2147483647): string
Public API: explicitly declared with @visibility public.

Generate a MySQL long integer literal.

Parameters

$minint
$maxint

Returns

string
Fix both bounds to obtain one valuedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $provider->longIntegerLiteral(min: 42, max: 42) // => '42'
Test cases 3
Calls 2
public function unsignedBigIntLiteral(int $minLength = 1, int $maxLength = 20): string
Public API: explicitly declared with @visibility public.

Generate a MySQL unsigned big integer literal. Leading zeroes are removed after sampling minLength to maxLength digits.

Parameters

$minLengthint
$maxLengthint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->unsignedBigIntLiteral(minLength: 4, maxLength: 4);
    preg_match('/^(0|[1-9][0-9]{0,3})$/', $token) // => 1
Test cases 2
Calls 2
public function decimalLiteral(int $precision = 10, int $scale = 2): string
Public API: explicitly declared with @visibility public.

Generate a MySQL decimal literal.

Parameters

$precisionint
$scaleint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->decimalLiteral(precision: 5, scale: 2);
    preg_match('/^[0-9]{1,3}\.[0-9]{2}$/', $token) // => 1
Test cases 3
Calls 2
public function floatLiteral(
    int $precision = 10,
    int $scale = 2,
    int $minExponent = -38,
    int $maxExponent = 38,
): string
Public API: explicitly declared with @visibility public.

Generate a MySQL float literal with exponent.

Parameters

$precisionint
$scaleint
$minExponentint
$maxExponentint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->floatLiteral(precision: 5, scale: 2, minExponent: 3, maxExponent: 3);
    preg_match('/^[0-9]{1,3}\.[0-9]{2}e3$/', $token) // => 1
Test cases 3
Calls 2
public function hexLiteral(int $minLength = 1, int $maxLength = 16): string
Public API: explicitly declared with @visibility public.

Generate a MySQL hexadecimal literal.

Parameters

$minLengthint
$maxLengthint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->hexLiteral(minLength: 4, maxLength: 4);
    preg_match('/^0x[0-9a-f]{4}$/', $token) // => 1
Test cases 3
Calls 2
public function quotedHexLiteral(int $minBytes = 1, int $maxBytes = 8): string
Public API: explicitly declared with @visibility public.

Generate a quoted MySQL hexadecimal literal.

Parameters

$minBytesint
$maxBytesint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->quotedHexLiteral(minBytes: 2, maxBytes: 2);
    preg_match('/^X\'[0-9a-f]{4}\'$/', $token) // => 1
Test cases 2
Calls 2
public function binaryLiteral(int $minLength = 1, int $maxLength = 64): string
Public API: explicitly declared with @visibility public.

Generate a MySQL binary literal.

Parameters

$minLengthint
$maxLengthint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->binaryLiteral(minLength: 4, maxLength: 4);
    preg_match('/^0b[01]{4}$/', $token) // => 1
Test cases 3
Calls 2
public function hostname(int $minParts = 1, int $maxParts = 4, int $maxPartLength = 63): string
Public API: explicitly declared with @visibility public.

Generate a MySQL hostname.

Parameters

$minPartsint
$maxPartsint
$maxPartLengthint

Returns

string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $token = $provider->hostname(minParts: 2, maxParts: 2, maxPartLength: 4);
    preg_match('/^[a-z0-9]{1,4}\.[a-z0-9]{1,4}$/', $token) // => 1
Test cases 3
Calls 2
public function replaceStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a REPLACE statement.

Parameters

$maxDepthint

Returns

string
Generate replace statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->replaceStatement(maxDepth: 0);
    preg_match('/\bREPLACE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function truncateStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a TRUNCATE statement.

Parameters

$maxDepthint

Returns

string
Generate truncate statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->truncateStatement(maxDepth: 0);
    preg_match('/\bTRUNCATE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function createIndexStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a CREATE INDEX statement.

Parameters

$maxDepthint

Returns

string
Generate create index statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->createIndexStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bINDEX\b/is', $sql) // => 1
Test cases 1
Calls 2
public function dropIndexStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a DROP INDEX statement.

Parameters

$maxDepthint

Returns

string
Generate drop index statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->dropIndexStatement(maxDepth: 0);
    preg_match('/\bDROP\b.*\bINDEX\b/is', $sql) // => 1
Test cases 1
Calls 2
public function beginStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a BEGIN statement.

Parameters

$maxDepthint

Returns

string
Generate begin statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->beginStatement(maxDepth: 0);
    preg_match('/\bBEGIN\b/is', $sql) // => 1
Test cases 1
Calls 2
public function commitStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a COMMIT statement.

Parameters

$maxDepthint

Returns

string
Generate commit statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->commitStatement(maxDepth: 0);
    preg_match('/\bCOMMIT\b/is', $sql) // => 1
Test cases 1
Calls 2
public function rollbackStatement(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a ROLLBACK statement.

Parameters

$maxDepthint

Returns

string
Generate rollback statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->rollbackStatement(maxDepth: 0);
    preg_match('/\bROLLBACK\b/is', $sql) // => 1
Test cases 1
Calls 2
public function expr(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a MySQL expression.

Parameters

$maxDepthint

Returns

string
Generate expr at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->expr(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function simpleExpr(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a simple MySQL expression.

Parameters

$maxDepthint

Returns

string
Generate simple expr at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->simpleExpr(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function literal(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a MySQL literal.

Parameters

$maxDepthint

Returns

string
Generate literal at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->literal(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function predicate(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a MySQL predicate.

Parameters

$maxDepthint

Returns

string
Generate predicate at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->predicate(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function whereClause(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a WHERE clause.

Parameters

$maxDepthint

Returns

string
Generate where clause at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->whereClause(maxDepth: 0);
    preg_match('/\bWHERE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function orderClause(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate an ORDER BY clause.

Parameters

$maxDepthint

Returns

string
Generate order clause at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->orderClause(maxDepth: 0);
    preg_match('/\bORDER\b.*\bBY\b/is', $sql) // => 1
Test cases 1
Calls 2
public function limitClause(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a LIMIT clause.

Parameters

$maxDepthint

Returns

string
Generate limit clause at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->limitClause(maxDepth: 0);
    preg_match('/\bLIMIT\b/is', $sql) // => 1
Test cases 1
Calls 2
public function tableReference(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a table reference.

Parameters

$maxDepthint

Returns

string
Generate table reference at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->tableReference(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function joinedTable(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a joined table.

Parameters

$maxDepthint

Returns

string
Generate joined table at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->joinedTable(maxDepth: 0);
    preg_match('/\bJOIN\b/is', $sql) // => 1
Test cases 1
Calls 2
public function tableIdent(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a table identifier.

Parameters

$maxDepthint

Returns

string
Generate table ident at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->tableIdent(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function subquery(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a subquery.

Parameters

$maxDepthint

Returns

string
Generate subquery at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->subquery(maxDepth: 0);
    preg_match('/\(.*\bSELECT\b.*\)/is', $sql) // => 1
Test cases 1
Calls 2
public function withClause(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a WITH clause (CTE).

Parameters

$maxDepthint

Returns

string
Generate with clause at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->withClause(maxDepth: 0);
    preg_match('/\bWITH\b.*\bAS\b/is', $sql) // => 1
Test cases 1
Calls 2
public function foreignKeyConstraint(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a named MySQL foreign-key table constraint.

Parameters

$maxDepthint

Returns

non-empty-string
Generate foreign key constraint at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->foreignKeyConstraint(maxDepth: 0);
    preg_match('/\bCONSTRAINT\b.*\bFOREIGN\b.*\bREFERENCES\b/is', $sql) // => 1
Test cases 1
Calls 2
public function updateJoinDerivedStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate an UPDATE whose joined source is a derived aggregate query.

Parameters

$maxDepthint

Returns

non-empty-string
Generate update join derived statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->updateJoinDerivedStatement(maxDepth: 0);
    preg_match('/\bUPDATE\b.*\bJOIN\b.*\bSELECT\b.*\bSET\b/is', $sql) // => 1
Test cases 1
Calls 2
public function insertSelectCompoundStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate an INSERT whose source is a compound SELECT.

Parameters

$maxDepthint

Returns

non-empty-string
Generate insert select compound statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->insertSelectCompoundStatement(maxDepth: 0);
    preg_match('/\bINSERT\b.*\bSELECT\b.*\bUNION\b.*\bALL\b/is', $sql) // => 1
Test cases 1
Calls 2
public function insertRowAliasUpsertStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a MySQL row-alias upsert introduced in MySQL 8.0.19.

Parameters

$maxDepthint

Returns

non-empty-string
Generate insert row alias upsert statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->insertRowAliasUpsertStatement(maxDepth: 0);
    preg_match('/\bINSERT\b.*\bAS\b.*\bDUPLICATE\b.*\bUPDATE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function insertFunctionUpsertStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate an upsert whose update expression calls a function.

Parameters

$maxDepthint

Returns

non-empty-string
Generate insert function upsert statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->insertFunctionUpsertStatement(maxDepth: 0);
    preg_match('/\bINSERT\b.*\bDUPLICATE\b.*\bUPDATE\b.*\bIF\b/is', $sql) // => 1
Test cases 1
Calls 2
public function fullTextSearchStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a query using the dialect full-text search syntax.

Parameters

$maxDepthint

Returns

non-empty-string
Generate full text search statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->fullTextSearchStatement(maxDepth: 0);
    preg_match('/\bSELECT\b.*\bMATCH\b.*\bAGAINST\b/is', $sql) // => 1
Test cases 1
Calls 2
public function temporaryTableStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a temporary-table declaration.

Parameters

$maxDepthint

Returns

non-empty-string
Generate temporary table statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->temporaryTableStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bTEMP(?:ORARY)?\b.*\bTABLE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function viewStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a view declaration.

Parameters

$maxDepthint

Returns

non-empty-string
Generate view statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->viewStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bVIEW\b.*\bAS\b/is', $sql) // => 1
Test cases 1
Calls 2
public function generatedColumnStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a table with a generated column.

Parameters

$maxDepthint

Returns

non-empty-string
Generate generated column statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->generatedColumnStatement(maxDepth: 0);
    preg_match('/\bGENERATED\b.*\bALWAYS\b.*\bAS\b/is', $sql) // => 1
Test cases 1
Calls 2
public function foreignKeyCascadeStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a foreign key with cascading update and delete actions.

Parameters

$maxDepthint

Returns

non-empty-string
Generate foreign key cascade statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->foreignKeyCascadeStatement(maxDepth: 0);
    preg_match('/\bREFERENCES\b.*\bCASCADE\b.*\bCASCADE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function partitionSelectStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a SELECT restricted to a named partition.

Parameters

$maxDepthint

Returns

non-empty-string
Generate partition select statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\MySqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->partitionSelectStatement(maxDepth: 0);
    preg_match('/\bSELECT\b.*\bPARTITION\b/is', $sql) // => 1
Test cases 1
Calls 2

Private surface 2§

Implementation details, listed for orientation only.

private Grammar $grammar
private SqlGenerator $sql

Test cases 96§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 95
Other tests reaching this symbol 1