Parses SQL schema statements for comparison to real table structures

package BackPress

 Methods

Helper function to flatten arrays

_flatten_array($array, $cut_branch = 0, $keep_child_array_keys = true

Parameters

$array

$cut_branch

$keep_child_array_keys

Evaluates the difference between a given set of SQL queries and real database structure

delta($db_object, $queries, $ignore = false, $execute = true

Parameters

$db_object

$queries

$ignore

$execute

Returns a table structure from a raw sql query of the form "CREATE TABLE foo" etc.

describe_table($query) 

The resulting array contains the original query, the columns as would be returned by DESCRIBE foo and the indices as would be returned by SHOW INDEX FROM foo on a real table

Parameters

$query

Builds a column definition as used in CREATE TABLE statements from an array such as those returned by DESCRIBE `foo` statements

get_column_definition($column_data) 

Parameters

$column_data

Builds an index definition as used in CREATE TABLE statements from an array similar to those returned by SHOW INDEX FROM `foo` statements

get_index_definition($index_data) 

Parameters

$index_data

Splits grouped SQL statements into queries within a highly structured array Only supports CREATE TABLE, INSERT and UPDATE

parse($sql) 

Parameters

$sql