Packagecom.maclema.mysql
Classpublic class Connection
InheritanceConnection Inheritance flash.events.EventDispatcher

A Connection is used to manage the creation and connection to a MySql Database. The connection class manages all data input/output from MySql using a Socket connection. Since all operations are asyncronous the Connection class also manages pooling queries and commands so they are executed in the order called.



Public Properties
 PropertyDefined By
  busy : Boolean
[read-only] Returns true if the connection is currently executing a query
Connection
  connected : Boolean
[read-only] Returns true or false indicating if this Connection instance is connected to MySql
Connection
  lastQueryStart : Number
[read-only] Returns the time the last query was executed
Connection
  poolSize : int
[read-only] Returns the current size of the command pool
Connection
  totalTX : Number
[read-only] Returns the number of bytes recieved since the connection was opened
Connection
  tx : Number
[read-only] Returns the number of bytes recieved since the last query
Connection
Public Methods
 MethodDefined By
  
Connection(host:String, port:int, username:String, password:String = null, database:String = null)
Creates a new Connection instance.
Connection
  
Changes the currently selected database database
Connection
  
connect(charSet:String = utf8):void
Opens the socket connection to the server.
Connection
  
Creates a new statement object
Connection
  
disconnect():void
Disconnects the socket from the server.
Connection
  
getServerInformation():ServerInformation
Returns the server information object for this connection
Connection
Events
 Event Summary Defined By
  Dispatched when the connection to the server is terminated.Connection
  Dispatched when successfully connected to the MySql ServerConnection
  Dispatched when a socket error occurs.Connection
  Dispatch when an SQL error occurs on connecting to MySqlConnection
Property Detail
busyproperty
busy:Boolean  [read-only]

Returns true if the connection is currently executing a query

This property can be used as the source for data binding.


Implementation
    public function get busy():Boolean
connectedproperty 
connected:Boolean  [read-only]

Returns true or false indicating if this Connection instance is connected to MySql

This property can be used as the source for data binding.


Implementation
    public function get connected():Boolean
lastQueryStartproperty 
lastQueryStart:Number  [read-only]

Returns the time the last query was executed


Implementation
    public function get lastQueryStart():Number
poolSizeproperty 
poolSize:int  [read-only]

Returns the current size of the command pool


Implementation
    public function get poolSize():int
totalTXproperty 
totalTX:Number  [read-only]

Returns the number of bytes recieved since the connection was opened


Implementation
    public function get totalTX():Number
txproperty 
tx:Number  [read-only]

Returns the number of bytes recieved since the last query


Implementation
    public function get tx():Number
Constructor Detail
Connection()Constructor
public function Connection(host:String, port:int, username:String, password:String = null, database:String = null)

Creates a new Connection instance.

Parameters
host:String
 
port:int
 
username:String
 
password:String (default = null)
 
database:String (default = null)
Method Detail
changeDatabaseTo()method
public function changeDatabaseTo(whatDb:String):MySqlToken

Changes the currently selected database database

Parameters

whatDb:String

Returns
MySqlToken
connect()method 
public function connect(charSet:String = utf8):void

Opens the socket connection to the server. You can optionally specify a character set. The specified charset should match a charset found in INFORMATION_SCHEMA.CHARACTER_SETS of the MySql database you are connecting to. It will then be converted to a compatible actionscript character set name and used for the duration of the connection. The default character set if utf8;

Parameters

charSet:String (default = utf8)

createStatement()method 
public function createStatement():Statement

Creates a new statement object

Returns
Statement
disconnect()method 
public function disconnect():void

Disconnects the socket from the server.

getServerInformation()method 
public function getServerInformation():ServerInformation

Returns the server information object for this connection

Returns
ServerInformation
Event Detail
close Event
Event Object Type: flash.events.Event

Dispatched when the connection to the server is terminated.

connect Event  
Event Object Type: flash.events.Event

Dispatched when successfully connected to the MySql Server

ioError Event  
Event Object Type: flash.events.IOErrorEvent

Dispatched when a socket error occurs.

sqlError Event  
Event Object Type: com.maclema.mysql.events.MySqlErrorEvent

Dispatch when an SQL error occurs on connecting to MySql