Package | com.ericfeminella.air.cairngorm.business |
Class | public class SQLService |
SQLService
wraps both the SQLStatement
and SQLConnection
in order to provide a Service
from which CRUD operations can be performed on a SQLite database
in the same manner as one would access typical RPC Services.
SQLService
supports both synchronous and asyncronous
transactions. A set of convenience methods have also been provided
to interface with the underlying SQLConnection
object
in order to perform transactions.
SQLService
defined by AIRServiceLocator
<?xml version="1.0" encoding="utf-8"?> <services:AIRServiceLocator xmlns:mx = "http://www.adobe.com/2006/mxml" xmlns:services = "com.ericfeminella.air.cairngorm.business." > <services:SQLService id = "service" localDatabaseFilePath = "{ File.desktopDirectory.nativePath.toString() }" localDatabaseFileName = "air.cairngorm.example.db" />
See also
Property | Defined by | ||
---|---|---|---|
connection : SQLConnection [read-only]
Retrieves the SQLService SQLConnection instance
| SQLService | ||
localDatabaseFileName : String
Retrieves the name of the local SQLite database
| SQLService | ||
localDatabaseFilePath : String
Retrieves the path to the local SQLite database
| SQLService | ||
result : SQLResult [read-only]
Retrieves the
SQLResult object instance from the last
statement execution. | SQLService | ||
statement : SQLStatement [read-only]
Retrieves the SQLService SQLStatement instance
| SQLService |
Property | Defined by | ||
---|---|---|---|
_connection : SQLConnection
Defines the
SQLConnection from which the
Service is connected
| SQLService | ||
_databaseFile : File
Defines a reference to the physical file which contains
a local SQLite database
| SQLService | ||
databaseFileName : String
Defines the qualified name of a local SQLite database
| SQLService | ||
databaseFilePath : String
Defines the absolute path to a local SQLite database
| SQLService | ||
_statement : SQLStatement
Defines the
SQLStatement from which queries
are executed
| SQLService |
Method | Defined by | ||
---|---|---|---|
Creates a new instance of
SQLService and
initiates members
| SQLService | ||
beginTransaction(lockType:String = null):void
Begins a transaction, within which all SQL statements executed
against the connection's database(s) are grouped.
| SQLService | ||
commitTransaction():void
Commits an existing transaction, causing any actions performed by
the transaction's statements to be permanently applied to the
database.
| SQLService | ||
databaseFile():File
Retrieves the local SQLite database file object
| SQLService | ||
execute(statement:String, dataType:Class = null, prefetch:int = -1.0):SQLResult
Executes a specific SQL operation against the
SQLService
synchronous mode
| SQLService | ||
executeAsync(statement:String, responder:ISQLResponder, dataType:Class = null, prefetch:int = -1.0):void
Executes a specific SQL operation against the
SQLService
in asynchronous mode
| SQLService | ||
open():SQLConnection
Provides a mechanism for opening the underlying SQLite database connection
in synchronous mode
| SQLService | ||
openAsync(openHandler:Function = null, errorHandler:Function = null):void
Provides a mechanism for opening the underlying SQLite database connection
in asynchronous mode
| SQLService | ||
rollbackTransaction():void
Rolls back an existing transaction created using the begin() method,
meaning all changes made by any SQL statements in the transaction
are discarded.
| SQLService |
_connection | property |
protected var _connection:SQLConnection
Defines the SQLConnection
from which the
Service is connected
connection | property |
connection:SQLConnection
[read-only]Retrieves the SQLService SQLConnection instance
Implementation public function get connection():SQLConnection
_databaseFile | property |
protected var _databaseFile:File
Defines a reference to the physical file which contains a local SQLite database
See also
databaseFileName | property |
protected var databaseFileName:String
Defines the qualified name of a local SQLite database
databaseFilePath | property |
protected var databaseFilePath:String
Defines the absolute path to a local SQLite database
localDatabaseFileName | property |
localDatabaseFileName:String
[read-write]Retrieves the name of the local SQLite database
Implementation public function get localDatabaseFileName():String
public function set localDatabaseFileName(value:String):void
localDatabaseFilePath | property |
localDatabaseFilePath:String
[read-write]Retrieves the path to the local SQLite database
Implementation public function get localDatabaseFilePath():String
public function set localDatabaseFilePath(value:String):void
result | property |
result:SQLResult
[read-only]
Retrieves the SQLResult
object instance from the last
statement execution. For synchronous mode only.
Typically one uses a SQLResult.data
object to access the
rows of data returned by a SELECT statement.
public function get result():SQLResult
_statement | property |
protected var _statement:SQLStatement
Defines the SQLStatement
from which queries
are executed
statement | property |
statement:SQLStatement
[read-only]Retrieves the SQLService SQLStatement instance
Implementation public function get statement():SQLStatement
SQLService | () | constructor |
public function SQLService()
Creates a new instance of SQLService
and
initiates members
beginTransaction | () | method |
public function beginTransaction(lockType:String = null):void
Begins a transaction, within which all SQL statements executed against the connection's database(s) are grouped.
ParameterslockType:String (default = null )
|
commitTransaction | () | method |
public function commitTransaction():void
Commits an existing transaction, causing any actions performed by the transaction's statements to be permanently applied to the database.
databaseFile | () | method |
public function databaseFile():File
Retrieves the local SQLite database file object
ReturnsFile — the local SQLite database file object
|
execute | () | method |
public function execute(statement:String, dataType:Class = null, prefetch:int = -1.0):SQLResult
Executes a specific SQL operation against the SQLService
synchronous mode
statement:String — SQL statement which to execute
|
|
dataType:Class (default = null ) — which handles the operation result / fault
|
|
prefetch:int (default = -1.0 ) — the type in which a result is to be deserialized
|
SQLResult |
executeAsync | () | method |
public function executeAsync(statement:String, responder:ISQLResponder, dataType:Class = null, prefetch:int = -1.0):void
Executes a specific SQL operation against the SQLService
in asynchronous mode
statement:String — SQL statement which to execute
|
|
responder:ISQLResponder — which handles the operation result / fault
|
|
dataType:Class (default = null ) — the type in which a result is to be deserialized
|
|
prefetch:int (default = -1.0 ) — prefetch
|
open | () | method |
public function open():SQLConnection
Provides a mechanism for opening the underlying SQLite database connection in synchronous mode
ReturnsSQLConnection — reference to the SQLConnection which has been opened
|
openAsync | () | method |
public function openAsync(openHandler:Function = null, errorHandler:Function = null):void
Provides a mechanism for opening the underlying SQLite database connection in asynchronous mode
ParametersopenHandler:Function (default = null ) — handler for an SQLEvent.OPEN event
|
|
errorHandler:Function (default = null ) — optional handler for an SQLErrorEvent.ERROR event
|
rollbackTransaction | () | method |
public function rollbackTransaction():void
Rolls back an existing transaction created using the begin() method, meaning all changes made by any SQL statements in the transaction are discarded.