[FX.php List] SQL strings transformed to FX.php functions

DC dan.cynosure at dbmscan.com
Wed Dec 7 12:27:17 MST 2005


First, a little background to my query...
I've been looking at some PHP MVC frameworks to help speed development.

Specifically, http://www.CakePHP.com . It looks like a good way to help 
organize a large project.

All of the frameworks I've looked at offer some degree of cross database 
compatibility - usually MySQL, SQLlite, MSSQL, PearDB, ADODB, and the 
like. Needless to say, none of them support my favorite database as a 
backend.

Now, here's a crazy idea... and please let me know what you think of it.

Build a transformation layer that would translate SQL statements into a 
series of FX.php function calls and PHP array manipulations to spit back 
the same format array that you would get if you were talking directly to 
a SQL engine (probably modeled after MySQL).

Leaving out all the connection and authentication steps...

For instance look at this terse SQL query:
$result = mysql_query('SELECT * FROM Persons WHERE FirstName="Tove"');

It would be translated by some kind of parser into this FX.php:
$request->SetDBData('Persons.fp5', 'web_layout', 'all');
$request->AddDBParam ('FirstName','Tove');
$result_array = $request->FMFind();
$sql_style_result = fetch_all_cols_from_fx_result($result_array);

which would be called like this:
$result=fxphp_sql_query('SELECT * FROM Persons WHERE FirstName="Tove"');

The resulting array would be returned as if it were a result from a SQL 
engine.

And this SQL query:
SELECT FirstName FROM Persons WHERE Month=12

Would automatically become:
$request->SetDBData('Persons.fp5', 'web_layout', 'all');
$request->AddDBParam ('Month',12);
$result_array = $request->FMFind();
$FirstNameCol = fetch_col_from_FX_result($result_array,'FirstName');

The function fetch_col_from_FX_result() would just cull result_array and 
reformat.

I know I could just turn on ODBC/JDBC and get SQL that way, but that is 
not always possible. And I believe that has issues with configuring 
operating system level drivers and such.

Does anyone have any thoughts on this? The ultimate goal is just to be 
able to use any PHP framework on top of FMP without building new 
databases in some SQL database. Basically, as a plugin to FX.php it 
would make FMP a viable backend for any number of PHP projects.

dan


More information about the FX.php_List mailing list