Class DB_MySQL

DB_MySQL

public class DB_MySQL

This class represents the entity of a MySQL database connection. One can query, connect, etc. It also provides static functions that allow one to create connections and process queries.


Constructor Summary
DB_MySQL(var $name, var $password, var $dbName, var $server)
          Constructs a DB_MySQL.
 
Method Summary
static int connect(var $name, var $password, var $server)
          Creates a database connection.
 int getDB()
          Returns a reference to the database handler.
 boolean getStatus()
          Returns of the status of the database.
static java.lang.String[] query(var $query, var $db)
          Queries the database link.
 void select(var $dbName)
          Selects a database to use for the object's database link.
 

Constructor Detail

DB_MySQL

public DB_MySQL(var $name,
                var $password,
                var $dbName,
                var $server)
Constructs a DB_MySQL. Given the minimal input of name and password, will create a database link. If a database name is passed, will automatically select usage of that database. If a server is passed, will override the default of "localhost".
Parameters:
$name - String specifying login
$password - String specifying password
$dbName - String specifying database name
$server - String specifying server
$dbName - Default Value: ""
$server - Default Value: "localhost"
Method Detail

connect

public static int connect(var $name,
                          var $password,
                          var $server)
Creates a database connection. Will return a database link.
Parameters:
$name - String specifying login
$password - String specifying password
$server - String specifying server to use
$server - Default Value: "localhost"

query

public static java.lang.String[] query(var $query,
                                       var $db)
Queries the database link. Will either use the passed database link, or, if nothing is passed, will use the object's database link. If the query is a SELECT query, will return the results. Otherwise, will return nothing.
Parameters:
$query - String specifying the SQL query
$db - int specifying the database link
$db - Default Value: ""

select

public void select(var $dbName)
Selects a database to use for the object's database link.
Parameters:
$dbName - String specifying the database to use

getDB

public int getDB()
Returns a reference to the database handler.

getStatus

public boolean getStatus()
Returns of the status of the database. FALSE indicates unable to open connection, while TRUE indicates database was opened successfully.