Вы находитесь на странице: 1из 3

SQL in AIR

**********
Uses for local SQL DB
**********************
* For a data-oriented application (address book i,e.)
* Fora document-oriented application,
* For a network-asware application (to store local data when there's no internet
to the synchronizer the app)
* To store local users' application settings (windows size, positions, etc.)
* Take into account
*****************
* Any AIR app would be able to open any DB file. (use encryption mechanism to
secure the DB)
About AIR DB and DB files
*************************
* An individual AIR local SQL DB is store as a single file on the computer's fil
e system
* The runtime includes all mechanism to manipulate data from the DBF (data base
file)
* The runtime does not specify how or where DB DATA is stored on the FS (file sy
stem). The DB is a single FS file.
* You CAN specify the location in the file system where the DBF is stored
* A single AIR app can access one or many separate DB (ie. separate DBF)
* You can locate your DB as needed by the design of your app on the FS, and file
access constraints of the OS
* Each user can have a separate DBF for their specific data, or a DBF can be acc
essed by all application users on a single computer for shared data
* Because the data is local to a single computer, data is not automatically shar
ed among users on different computers.
* The local QDL DBE (data base engine) doen't provide any capability to execute
SQL statements agains a remote or server-based DB
SQL in Actionscript
*******************
* To work with SQL DB in AS3, you use instances of these classes in the flash.da
ta package
*flash.data.SQLConnection* Provides the means to create and open databases (DBF)
, as well as methods for performing database-level operations and for controllin
g DB transactions
*flash.data.SQLStatement* Represents a single SQL statement (a single query com
mand) that is executed on a DB, including defining the statement text and settin
g paramenters values
*flash.data.SQLResult* Provides a way to get information about or results from e
xecuting statements, such as the result rows from a SELECT statement, the number
of rows affected by and UPDATE or DELETE statement, and so forth
* To obtain schema information describing the structure of the DB, you can use t
heese clases in the flash.data package.

*flash.data.SQLSchemaResult*. Serves as a container for database schema result


s generated by calling the SQLConnection.loadSchema() method
*flash.data.SQLTableSchema*. Provides information describing a single table i
n a DB
*flash.data.SQLViewSchema*. Provides information describing a single view in
a DB
*flash.data.SQLIndexSchema*. Provides information describing a single column
of a table of view in a database.
*flash.data.SQLTriggerShcema*. Provides information describing a single trigger
in a DB
* Other classes in the flash.data package provide constants that are used with t
he *SQLConnection* class and the *SQLColumnSchema* class
*flash.data.SQLMode*. Defines a set of constants representing
the possible values for the *openMode* parameter of the SQLConnection.open() and
SQLConnectino.openAsyn() methods.
*flash.data.SQLCoumnNameStyle*. Defines a set of constants representing
the possible values for the *SQLConnection.columnNameStyle* property.
*flash.data.SQLTransactionLockType*. Defines a set of constants representing
the possible values for option parameter of the *SQLConnection.begin()* method.
*flash.data.SQLCollationType*. Defines a set of constants representing
the possible values for the *SQLColumnSchema.defaultCollationType* property and
the defaultCollationType parameter of the SQLColumnSchema() constructor

* The following classes in the flash.events package represents the events (and s
upporting constants) to use.
*flash.data.SQLEvent*. Defines the events that a SQLConnection or SQLSt
atement instance dispatches when any of its operations execute successfully. Eac
h operation has an associated event type constant defined in the SQLEvent class
*flash.data.SQLErrorEvent*. Defines the event that a SQLConnection or SQLSta
tement instance dispatches when any of its operations results in an error
*flash.data.SQLUpdateEvent*. Defines the event that a SQLConnection instances
dispatches when table and data in one of its connected databases changes as a r
esult of an INSERT, UPDATE, or DELETE SQL statement being executed.
* Finally, the following classes in the flash.errors package provide information
about database operation errors:
*flash.data.SQLError*. Provides information about a DB operation error,
including: the operation that was being attempted and the cause of the failure.
*flash.data.SQLErrorEvent*. Defines a set of constants representing the pssi
ble values for the sQLError class's operation property, which indicates the data
base operation that resulted in an error.

About synchronous and asynchronous execution modes


***************************************************
Ther are two modes of specify the DB operations execution modes: Asynchronouse a
nd Synchronous execution mode.

*Asynchronouse execution mode*


* You give the runtime an instruction and the runtime dispatches an event when y
our requested operation completes of fails.
* First you tell the DB engine to perform an operation. The DB engine does it wo
rk in the background while the application continues running.
* When the operation is completed (or when it fails) the DB engine dispatches an
event.
* this mode has the following benefits
** The runtime performs the DBO (data base operations) in the background while t
he main application code continues executing.
** If the DBO takes a notable amount of time, the application code continues to
run
** The user can continue to interact with the app whitout the screen freezing.
** Asynchronous operation code can be more comple to write than other code. This
complexity is ussully in cases where multiple dependent operations must be divi
ded up among various event listeners methods.

*Synchronous execution mode*


* Operations doesn't run in the background
* They run in the sam execution sequence as all other application mode
* You tell the DBE (data base engine) to perform an operation. The code then pau
ses at that point while the DBE does it works
* Whene the operation complete, execution continues with the next line of your c
ode.

*General aspects*
* Whether operations execute asynchronously or synchronously is set at the SQLCo
nnection level.
* Using a single DBC (data base connection) you can't execute some operations or
statements asynchronously and other synchronously
* You specify whether a SQLConnection operates in Synch or Asynch execution mode
by calling a SQLConnection method to open a DB
* Calling SQLConnection.open() the connection operates in sync execution mode.
* Calling SQLConnection.openAsync() the connection operates in async execution m
ode.
* Once a SQLConnection instance is connected to a DB using open() or openAsync()
, it is fixed to sync or async execution mode unless you close a reopen the conn
ection to the DB

Вам также может понравиться