DB Class Reference

Allows you to easily connect to a database. More...

Public Member Functions

 manualConnect ($dbname, $username, $password, $host="localhost")
 Provides a manual way to connect to the database.
 connect ()
 Connects to the database.
 activeConnect ()
 Creates a persistent connection to a database.
 switchUser ($username, $password)
 Switches the user logged in. Does not work with manualConnect().
 query ($query)
 Queries the database.
 cleanString ($str, $clean_html=false)
 Sanitizes a string from special SQL characters.
 cleanInt ($int)
 Makes sure an integer input is actually an integer.
 disconnect ()
 Disconnects from the database.

Data Fields

 $host = "localhost"
 The host, where the database is located server-wise.
 $username = null
 The username used to access the database.
 $password = null
 The password of the user used to access the database.
 $dbname = null
 The name of the database you are connecting to.

Detailed Description

Allows you to easily connect to a database.

Provides an easy way to connect to a MySQL database and sanitize input to avoid XSS Cross Site Scripting exploits and SQL Injection.

Definition at line 14 of file db.php.


Member Function Documentation

activeConnect (  ) 

Creates a persistent connection to a database.

Uses the host, username, password, and dbname variables to connect.

Definition at line 71 of file db.php.

cleanString ( str,
clean_html = false 
)

Sanitizes a string from special SQL characters.

Parameters:
clean_html Determines whether HTML characters are escaped

Definition at line 102 of file db.php.

connect (  ) 

Connects to the database.

Uses the host, username, password, and dbname variables to connect.

Definition at line 55 of file db.php.

manualConnect ( dbname,
username,
password,
host = "localhost" 
)

Provides a manual way to connect to the database.

This is only recommended for testing and debugging or only planning on connecting to the database once, the connect() function is recommended otherwise.

Parameters:
dbname The name of the database you are connecting to.
username The username used to access the database.
password The password of the user used to access the database.
host The host, where the database is located server-wise.

Definition at line 39 of file db.php.

query ( query  ) 

Queries the database.

It returns true if the query is successful and false if it is unsuccessful.

Definition at line 94 of file db.php.


Field Documentation

$host = "localhost"

The host, where the database is located server-wise.

This is most likely to be "localhost". This only needs to be set if you plan on using the connect() function.

Definition at line 22 of file db.php.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables

Generated on Tue Mar 9 17:07:08 2010 for AnLib by  doxygen 1.6.2