Propel 2 API
Class

Propel\Generator\Util\SqlParser

class SqlParser

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, ConnectionInterface $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, ConnectionInterface $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(string $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 35
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 47
public string getSQL()

Gets the inner SQL string for this object.

Return Value

string The SQL string to parse

at line 61
static public integer executeString(string $input, ConnectionInterface $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
ConnectionInterface $connection a connection object

Return Value

integer the number of executed statements

at line 75
static public integer executeFile(string $file, ConnectionInterface $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
ConnectionInterface $connection a connection object

Return Value

integer the number of executed statements

at line 130
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 159
static public array parseFile(string $file)

Explodes a SQL file into an array of SQL statements.

Parameters

string $file The absolute path to the file to parse

Return Value

array A list of SQL statement strings

at line 168
public convertLineFeedsToUnixStyle()

at line 173
public stripSQLCommentLines()

at line 186
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 203
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