Skip to main content

SQL functions for Flash

By May 10, 2003Uncategorized

fSQLfunctions.as
By: Bob Clagett – [email protected]

This is a set of 3 simple string functions, for preparing data to go into a SQL database.
They are just a simple port from some ASP functions that we use.

They depend on “stringutils.as” by Mike Chambers, so make sure to include it (or modify the lines concerning “REPLACE” to use your own replace functions.

The file includes:
fSQLdate – for adding the proper date delimiter (generally or #
fSQLstr – for adding proper string delimiter
fSQLval – for forcing a numerical value and removing unusable characters.

Here is a simple usage example.

#include “stringutils.as”
#include “fSQLfunctions.as”

var tString = “bob’s cool”;
var tNum=”5″;
var tDate = “3/4/2003”;

// if you were to build a SQL query directly in Flash

var SQLquery=”select * from news where title=”+fSQLStr(tString)+” and comments=”+fSQLval(tNum)+” and newsDate=”+fSQLdate(tDate);

trace(SQLquery);

The above code would trace

select * from news where title=’bob”s cool’ and comments=5 and newsDate=’3/4/2003′

DOWNLOAD .AS