Packageorg.libspark.utils
Classpublic class SqlUtil

(Flex Only)



Public Methods
 MethodDefined by
  
Constructor
SqlUtil
  
buildInsert(table:String, rows:ArrayCollection):String
[static] Build Insert SQL Statement
SqlUtil
  
buildSelectAll(db:SQLConnection, table:String):String
[static] Build Select All SQL Statement
SqlUtil
  
buildTableDefs(db:SQLConnection, table:String):Array
[static] Build Create Table SQL Statement
SqlUtil
  
createIndex(db:SQLConnection, table:String, indexDefs:ArrayCollection):Boolean
[static] Create index of the specified table
SqlUtil
  
createTable(db:SQLConnection, table:String, tableDefs:ArrayCollection):Boolean
[static] Create table to the specified database
SqlUtil
  
deleteRow(db:SQLConnection, table:String, keyColumn:String, keyValue:int):Boolean
[static] Delete row from the specified table
SqlUtil
  
dropIndex(db:SQLConnection, index:String):Boolean
[static] Drop the specified index from the DataBase
SqlUtil
  
dropTable(db:SQLConnection, table:String):Boolean
[static] Drop the specified table from the DataBase
SqlUtil
  
executeSQLStatement(db:SQLConnection, sql:String):Object
[static] private method
SqlUtil
  
existsIndex(db:SQLConnection, table:String, index:String):Boolean
[static] Check if the index exists in the specified table
SqlUtil
  
existsTable(db:SQLConnection, table:String):Boolean
[static] Check if the table exists in the database
SqlUtil
  
getColumnDef(db:SQLConnection, table:String):ArrayCollection
[static] Get the columns definition of the specified table
SqlUtil
  
getData(db:SQLConnection, sql:String):Array
[static] Get the Data & Column Defs of the table
SqlUtil
  
getIndexList(db:SQLConnection, table:String):ArrayCollection
[static] Get the index list of the specified table
SqlUtil
  
getRowCount(db:SQLConnection, table:String):uint
[static] Get the row count of the table
SqlUtil
  
getTableList(db:SQLConnection):Array
[static] Get the table list of the specified DataBase
SqlUtil
  
insertRow(db:SQLConnection, table:String, rows:ArrayCollection):Boolean
[static] Insert row to the specified table
SqlUtil
  
trancateTable(db:SQLConnection, table:String, keyColumn:String):Boolean
[static] Remove the whole data of the specified table
SqlUtil
  
updateRow(db:SQLConnection, table:String, keyColumn:String, keyValue:int, updateColumn:String, updateValue:String, updateType:String):Boolean
[static] Update row of the specified table
SqlUtil
Constructor detail
SqlUtil()constructor
public function SqlUtil()

Constructor

Method detail
buildInsert()method
public static function buildInsert(table:String, rows:ArrayCollection):String

Build Insert SQL Statement

Parameters
table:String — Table to insert data
 
rows:ArrayCollection — Data to insert

Returns
String — Insert SQL Statement
buildSelectAll()method 
public static function buildSelectAll(db:SQLConnection, table:String):String

Build Select All SQL Statement

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — Table to build the SQL statement

Returns
String — Select All SQL Statement
buildTableDefs()method 
public static function buildTableDefs(db:SQLConnection, table:String):Array

Build Create Table SQL Statement

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — Table to build the SQL statement

Returns
Array — Create Table SQL Statement
createIndex()method 
public static function createIndex(db:SQLConnection, table:String, indexDefs:ArrayCollection):Boolean

Create index of the specified table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table to create index
 
indexDefs:ArrayCollection — ArrayCollection of the index definition and it contains the following params. - name : Index name - columns: The list of the column

Returns
Boolean — true/false If it succeed to create the index
createTable()method 
public static function createTable(db:SQLConnection, table:String, tableDefs:ArrayCollection):Boolean

Create table to the specified database

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table name
 
tableDefs:ArrayCollection — ArrayCollection of the table definition and it contains the following params. - name : Column name - type : The data type of the column - primaryKey : If the column is primary key - autoIncrement: If it will increment the value automatically - allowNull : If the column allows null value

Returns
Boolean — true/false If it succeed to create the table
deleteRow()method 
public static function deleteRow(db:SQLConnection, table:String, keyColumn:String, keyValue:int):Boolean

Delete row from the specified table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table to delete the row
 
keyColumn:String — The column name that specify the row
 
keyValue:int — The column value that specify the row

Returns
Boolean — true/false If it succeed to delete the row
dropIndex()method 
public static function dropIndex(db:SQLConnection, index:String):Boolean

Drop the specified index from the DataBase

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
index:String — The Index to drop from DataBase

Returns
Boolean — true/false If it succed to drop the index
dropTable()method 
public static function dropTable(db:SQLConnection, table:String):Boolean

Drop the specified table from the DataBase

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The Table to drop from DataBase

Returns
Boolean — true/false If it succed to drop the table
executeSQLStatement()method 
public static function executeSQLStatement(db:SQLConnection, sql:String):Object

private method

Parameters
db:SQLConnection
 
sql:String

Returns
Object
existsIndex()method 
public static function existsIndex(db:SQLConnection, table:String, index:String):Boolean

Check if the index exists in the specified table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table if contains the index
 
index:String — The index name to check

Returns
Boolean — true/false If the index exists in the table
existsTable()method 
public static function existsTable(db:SQLConnection, table:String):Boolean

Check if the table exists in the database

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table name to check

Returns
Boolean — true/false If the table exists in the table
getColumnDef()method 
public static function getColumnDef(db:SQLConnection, table:String):ArrayCollection

Get the columns definition of the specified table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table name which you want the column defs

Returns
ArrayCollection — The ArrayCollection of the columns definition and it contains the following params - name : Column name - type : The Data type of the column - primaryKey : If this column is primary key - autoIncrement: If this column increment automatically - allowNull : If this column allow null value
getData()method 
public static function getData(db:SQLConnection, sql:String):Array

Get the Data & Column Defs of the table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
sql:String — The SQL string

Returns
Array — result The Array which contains column defs and data The following are the description - result[0]: The Array of the columns name - result[1]: The SQLResult of the sql which executed
getIndexList()method 
public static function getIndexList(db:SQLConnection, table:String):ArrayCollection

Get the index list of the specified table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table to get the list of index

Returns
ArrayCollection — The ArrayCollection of the index and it contains the following params - name : Index name - columns: The column list
getRowCount()method 
public static function getRowCount(db:SQLConnection, table:String):uint

Get the row count of the table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table name which you want to get the row count

Returns
uint — The row count of the table
getTableList()method 
public static function getTableList(db:SQLConnection):Array

Get the table list of the specified DataBase

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase

Returns
Array — The Array of the table name
insertRow()method 
public static function insertRow(db:SQLConnection, table:String, rows:ArrayCollection):Boolean

Insert row to the specified table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table to insert the data
 
rows:ArrayCollection — The ArrayCollection of the data to insert and it contains the following params - column: Column name - value : Column value - type : Data type of the column

Returns
Boolean — true/false If it succeed to insert the row data
trancateTable()method 
public static function trancateTable(db:SQLConnection, table:String, keyColumn:String):Boolean

Remove the whole data of the specified table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table to remove the whole data
 
keyColumn:String

Returns
Boolean — true/false If it succed to trancate the table
updateRow()method 
public static function updateRow(db:SQLConnection, table:String, keyColumn:String, keyValue:int, updateColumn:String, updateValue:String, updateType:String):Boolean

Update row of the specified table

Parameters
db:SQLConnection — The SQLConnection of the specified DataBase
 
table:String — The table to update the data
 
keyColumn:String — The column name to specify the row
 
keyValue:int — The column value to specify the row
 
updateColumn:String — The column name to update
 
updateValue:String — The column value to update
 
updateType:String — The data type of the column to update

Returns
Boolean — true/false If it succeed to update the row data