Packagephi.interfaces
Interfacepublic interface IDatabase
ImplementorsDatabase

The interface definition for a Database object.

A IDatabase implementor have these responsibilities:

See also

phi.interfaces.IQuery


Public Properties
 PropertyDefined by
  connection : ConnectionData
[write-only]
IDatabase
Public Methods
 MethodDefined by
  
connect(name:String, user:String, pass:String, host:String, db:String, bDefault:Boolean = false):void
Create a new connection with a remote application server.
IDatabase
  
disconnect(name:String):void
Disconnect from a previous connection
IDatabase
  
getConnections():Number
Get the number of current open connections.
IDatabase
  
Get the default connection name
IDatabase
  
retrieveConnection(connectionName:String):ConnectionData
Retrieve an connection information.
IDatabase
  
setDefaultConnection(name:String):void
Set a connection as a default
IDatabase
Property detail
connectionproperty
connection:ConnectionData  [write-only]Implementation
    public function set connection(value:ConnectionData):void
Method detail
connect()method
public function connect(name:String, user:String, pass:String, host:String, db:String, bDefault:Boolean = false):void

Create a new connection with a remote application server. This connection can be use for execute SQL statements to a database.
More then one connection can be made but you must enter at least one connection for the Database object to work.

Parameters
name:String — the name of the connection
 
user:String — the username of the remote application server
 
pass:String — the password of the remote application server
 
host:String — the server ip
 
db:String — the database name
 
bDefault:Boolean (default = false) — set this connection as a default connection

Throws
— Error if a connection with the same name allready exist.

Example
The following code create 2 connections:
   var db:IDatabase = Database.getInstance();
   
   db.connect("conn1", "pop", "poppass", "localhost", "yb20");
   db.connect("conn2", "pop", "poppass", "localhost", "test_db");
   
   

disconnect()method 
public function disconnect(name:String):void

Disconnect from a previous connection

Parameters
name:String — the name of the connection

Throws
— Error if the connection don't exist.
getConnections()method 
public function getConnections():Number

Get the number of current open connections.

Returns
Number — the number of current open connections.
getDefaultConnectionName()method 
public function getDefaultConnectionName():String

Get the default connection name

Returns
String — a string with the name of the default connection
retrieveConnection()method 
public function retrieveConnection(connectionName:String):ConnectionData

Retrieve an connection information.

Parameters
connectionName:String — the name of the connection to retrieve.

Returns
ConnectionData — an ConnectionData instance previously created with the connect function.

Throws
— Error if the connection don't exist.
setDefaultConnection()method 
public function setDefaultConnection(name:String):void

Set a connection as a default

Parameters
name:String — the connection name