FfDbHelper
public class FfDbHelper
Field Summary | |
---|---|
mixed | A handle to the database connection. |
mixed | The database name. |
mixed | The database hostname or IP. |
mixed | The database username's password. |
mixed | The database username. |
Method Summary | |
---|---|
void | connect(boolean ignoreError) Attempts to connect to the database using a persistent connection and if this fails attempts using a non-persitent connection. |
resource | delete(array assocArray, string tableName, boolean ignoreError) Uses an associative array to delete data in a database table. |
void | getDbArray(array values) Returns an array of database values processed with getDbValue(). |
string | getDbValue(mixed value) Escapes the string and then wraps it in single quotes value for easy use in an SQL query. |
array | getList(string sql, boolean ignoreError) Returns an array of values or a "column" or values from the database. |
array | getRows(string sql, boolean ignoreError) Returns an array of rows of data from the database. |
string | getSelectClause(mixed attrs, array an) Returns the parameter section of the SQL select clause generated from an associative array. |
string | getSimpleValue(string sql, boolean ignoreError) Returns a single value of data from the database. |
array | getSimpleValues(string sql, boolean ignoreError) Returns an array of values or a "row" of values from the database. |
resource | insert(array assocArray, string tableName, boolean ignoreError) Uses an associative array to insert data in a database table. |
void | insertAttrChanges(string tableName, array changes, string primaryKey, string attrChangesTableName, string userId, boolean ignoreError) Uses a database table to record changes to a row of data and create an audit trail. |
void | Echos a error message page explaining that there was a problem connecting to the database and to try back later. |
resource | query(string sql, boolean ignoreError) Executes an SQL query. |
array | select(array assocArray, string tableName, string whereClause, boolean ignoreError) Uses an associative array to select a row of data from a database table. |
array | splitResultSet(mixed rs) Retrieves separate columns of data from a result set. |
resource | update(array assocArray, string tableName, string whereClause, boolean ignoreError) Uses an associative array to update data in a database table. |
public mixed $dbLink
A handle to the database connection.
public mixed $dbName
The database name.
public mixed $host
The database hostname or IP.
public mixed $password
The database username's password.
public mixed $user
The database username.
public void connect(boolean ignoreError)
Attempts to connect to the database using a persistent connection and if this fails attempts using a non-persitent connection. After the connectio has been established the specified database is selected.
public resource delete(array assocArray, string tableName, boolean ignoreError)
Uses an associative array to delete data in a database table.
public void getDbArray(array values)
Returns an array of database values processed with getDbValue().
public string getDbValue(mixed value)
Escapes the string and then wraps it in single quotes value for easy use in an SQL query. Furthermore, if the field value is null then the database value will be "null" and not "'null'".
public array getList(string sql, boolean ignoreError)
Returns an array of values or a "column" or values from the database. For example, this method can be used with "SELECT username FROM users"
public array getRows(string sql, boolean ignoreError)
Returns an array of rows of data from the database. This method is useful for quickly grabbing a sizeable chunk of table data in an array, however it can be a waste if all the data is not going to be used. For better efficiency (data storage) you may want to use query(). For example, this method can be used with "SELECT username,first_name,last_name FROM users"
public string getSelectClause(mixed attrs, array an)
Returns the parameter section of the SQL select clause generated from an associative array.
public string getSimpleValue(string sql, boolean ignoreError)
Returns a single value of data from the database. For example, this method can be used with, "SELECT username FROM users WHERE id='1'"
public array getSimpleValues(string sql, boolean ignoreError)
Returns an array of values or a "row" of values from the database. For example, this method can be used with, "SELECT username,first_name,last_name FROM users WHERE id='1'"
public resource insert(array assocArray, string tableName, boolean ignoreError)
Uses an associative array to insert data in a database table.
public void insertAttrChanges(string tableName, array changes, string primaryKey, string attrChangesTableName, string userId, boolean ignoreError)
Uses a database table to record changes to a row of data and create an audit trail.
public void printServerDownError()
Echos a error message page explaining that there was a problem connecting to the database and to try back later.
public resource query(string sql, boolean ignoreError)
Executes an SQL query. If an error is detected and ignoreError is false, an error message page is echoed to the screen and script execution is halted. Note: This method automatically connects to the database when needed.
public array select(array assocArray, string tableName, string whereClause, boolean ignoreError)
Uses an associative array to select a row of data from a database table.
public array splitResultSet(mixed rs)
Retrieves separate columns of data from a result set. For example, when applying this method to the result set returned from "SELECT username,users FROM users", this method will return username and users arrays with corresponding indices.
public resource update(array assocArray, string tableName, string whereClause, boolean ignoreError)
Uses an associative array to update data in a database table.
FfDbHelper contains helper rountines for accessing a database.