fSQLTranslationclassv1.0.0b15

Takes a subset of SQL from MySQL, PostgreSQL, Oracle, SQLite and MSSQL and translates into the various dialects allowing for cross-database code

Changes:
1.0.0b15Fixed a bug with MSSQL national character conversion when running a SQL statement with a sub-select containing joins 12/18/09
1.0.0b14Changed PostgreSQL to cast columns in LOWER() calls to VARCHAR to allow UUID columns (which are treated as a VARCHAR by fSchema) to work with default primary key ordering in fRecordSet 12/16/09
1.0.0b13Added a parameter to enableCaching() to provide a key token that will allow cached values to be shared between multiple databases with the same schema 10/28/09
1.0.0b12Backwards Compatibility Break - Removed date translation functionality, changed the signature of translate(), updated to support quoted identifiers, added support for PostgreSQL, MSSQL and Oracle schemas 10/22/09
1.0.0b11Fixed a bug with translating MSSQL national columns over an ODBC connection 9/18/09
1.0.0b10Changed last bug fix to support PHP 5.1.6 9/18/09
1.0.0b9Fixed another bug with parsing table aliases for MSSQL national columns 9/18/09
1.0.0b8Fixed a bug with parsing table aliases that occurs when handling MSSQL national columns 9/9/09
1.0.0b7Fixed a bug with translating NOT LIKE operators in PostgreSQL 7/15/09
1.0.0b6Changed replacement values in preg_replace() calls to be properly escaped 6/11/09
1.0.0b5Update code to only translate data types inside of CREATE TABLE queries 5/22/09
1.0.0b4Added the missing __get() method for callback support 5/6/09
1.0.0b3Added Oracle and caching support, various bug fixes 5/4/09
1.0.0b2Fixed a notice with SQLite foreign key constraints having no ON clauses 2/21/09
1.0.0bThe initial implementation 9/25/07

Static Methods

::compose() protected

Composes text using fText if loaded

Signature

string compose( string $message, mixed $component )

Parameters

string $message The message to compose
mixed $component [, ... ] A string or number to insert into the message

Returns

The composed and possible translated message

::sqliteCotangent() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Callback for custom SQLite function; calculates the cotangent of a number

Signature

numeric sqliteCotangent( numeric $x )

Parameters

numeric $x The number to calculate the cotangent of

Returns

The contangent of $x

::sqliteDate() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Callback for custom SQLite function; returns the current date

Signature

string sqliteDate( )

Returns

The current date

::sqliteLogBaseFirst() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Callback for custom SQLite function; calculates the log to a specific base of a number

Signature

numeric sqliteLogBaseFirst( integer $base, numeric $num )

Parameters

integer $base The base for the log calculation
numeric $num The number to calculate the logarithm of

Returns

The logarithm of $num to $base

::sqliteSign() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Callback for custom SQLite function; returns the sign of the number

Signature

numeric sqliteSign( numeric $x )

Parameters

numeric $x The number to change the sign of

Returns

-1 if a negative sign, 0 if zero, 1 if positive sign

::sqliteTime() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Callback for custom SQLite function; returns the current time

Signature

string sqliteTime( )

Returns

The current time

::sqliteTimestamp() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Callback for custom SQLite function; returns the current timestamp

Signature

string sqliteTimestamp( )

Returns

The current date

Methods

->__construct() public

Sets up the class and creates functions for SQLite databases

Signature

fSQLTranslation __construct( fDatabase $database, mixed $connection )

Parameters

fDatabase $database The database being translated for
mixed $connection The connection resource or PDO object

->__get() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

All requests that hit this method should be requests for callbacks

Signature

callback __get( string $method )

Parameters

string $method The method to create a callback for

Returns

The callback for the method requested

->clearCache() public

Clears all of the schema info out of the object and, if set, the fCache object

Signature

void clearCache( )

->enableCaching() public

Sets the schema info to be cached to the fCache object specified

Signature

void enableCaching( fCache $cache, $key_token=NULL )

Parameters

fCache $cache The cache to cache to
$key_token

->enableDebugging() public

Sets if debug messages should be shown

Signature

void enableDebugging( boolean $flag )

Parameters

boolean $flag If debugging messages should be shown

->translate() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Translates Flourish SQL into the dialect for the current database

Signature

array translate( array $statements )

Parameters

array $statements The SQL statements to translate

Returns

The translated SQL statements all ready for execution. Statements that have been translated will have string key of the original SQL, all other will have a numeric key.