Propel API
Class

PropelSQLParser

class PropelSQLParser

Service class for parsing a large SQL string into an array of SQL statements

Methods

setSQL(string $sql)

Sets the inner SQL string for this object.

string getSQL()

Gets the inner SQL string for this object.

static integer executeString(string $input, PDO $connection)

Execute a list of DDL statements based on a string Does not use transactions since they are not supported in DDL statements

static integer executeFile(string $file, PDO $connection)

Execute a list of DDL statements based on the path to the SQL file Does not use transactions since they are not supported in DDL statements

static array parseString(string $input)

Explodes a SQL string into an array of SQL statements.

static array parseFile($file)

Explodes a SQL file into an array of SQL statements.

convertLineFeedsToUnixStyle()

stripSQLCommentLines()

array explodeIntoStatements()

Explodes the inner SQL string into statements based on the SQL statement delimiter (;)

string getNextStatement()

Gets the next SQL statement in the inner SQL string, and advances the cursor to the end of this statement.

Details

at line 32
public setSQL(string $sql)

Sets the inner SQL string for this object.

Also resets the parsing cursor (see getNextStatement)

Parameters

string $sql The SQL string to parse

at line 44
public string getSQL()

Gets the inner SQL string for this object.

Return Value

string The SQL string to parse

at line 58
static public integer executeString(string $input, PDO $connection)

Execute a list of DDL statements based on a string Does not use transactions since they are not supported in DDL statements

Parameters

string $input The SQL statements
PDO $connection a connection object

Return Value

integer the number of executed statements

at line 72
static public integer executeFile(string $file, PDO $connection)

Execute a list of DDL statements based on the path to the SQL file Does not use transactions since they are not supported in DDL statements

Parameters

string $file the path to the SQL file
PDO $connection a connection object

Return Value

integer the number of executed statements

at line 123
static public array parseString(string $input)

Explodes a SQL string into an array of SQL statements.

Parameters

string $input The SQL code to parse

Return Value

array A list of SQL statement strings

at line 152
static public array parseFile($file)

Explodes a SQL file into an array of SQL statements.

Parameters

$file

Return Value

array A list of SQL statement strings

at line 160
public convertLineFeedsToUnixStyle()

at line 165
public stripSQLCommentLines()

at line 178
public array explodeIntoStatements()

Explodes the inner SQL string into statements based on the SQL statement delimiter (;)

Return Value

array A list of SQL statement strings

at line 195
public string getNextStatement()

Gets the next SQL statement in the inner SQL string, and advances the cursor to the end of this statement.

Return Value

string A SQL statement