Apex Software Platform
db:: Service -- Back-End Database (mySQL)
This service provides access to the back-end database, which by default is mySQL, although other database engines such as PostgreSQL or Oracle can be easily integrated. As with all services, the methods can be accessed statically providing easy and efficient access.
Placeholders are fully supported to properly sanitize all SQL queries, helping prevent SQL injection attacks. All placeholders begin with the % sign, followed by one or two characters. For example:
In the above example, the value of the status (%s) column must be a string, and the value of the group_id (%i) column must be an integer. The actual values are then passed as additional parameters to the function, and are properly checked and sanitized before being sent to the mySQL database engine. The below table lists all available placeholders:
Placeholder | Description ------------- |------------- %s | String %i | Integer, no decimal points %d | Decimal %b | Boolean, only allowed values are 1 / 0 %e | E-mail address %url | URL %ds | Date stamp, must be formatted in YYYY-MM-DD %ts | Timestampe, must be formatted in HH:II:SS %ls | For the LIKE operand. Sanitizes the value, and surrounds it with '%' characters. For example, the value "john" becomes "'%john%'"
db::query(string $sql, array $args)
Description: Performs any SQL statement against the database, but is generally used for SELECT statements,
and simply returns the result of the
Description: Inserts a new row into the specified database table.
Description: Updates one or more rows within the provided table name of the database.
Description: Deletes rows from the specified table.
array db::get_row(string $sql, array $args)</api
Description: Get the first row found using the given SQL query, and returns an associative array of the values. Returns false if no row exists.
Description: Similiar to the
Description: Returns a one-dimensional array of one specific column within a database table.
**Description:* Returns an associative array of the two columns defined within the SQL statement. Useful for creating a quick key-value pair from a database table.
Description: Returns the first column from the first row of the resulting SQL statement. Useful for getting a single field from a single row from the database.
Description: Simply returns the ID# of the last row inserted into a table with an id column that auto increments.
Description: Returns a one-dimensional array of all tables within the database.
** Description:** Returns an one-dimenational array of all columns within the given table provided. If
Description: Begins a new database transaction.
Description: Submits the currently open database transaction.
Description: Rollsback the currently open database transaction.
Need a Developer?
Taking work, any size or scope, and your imagination is the only limit. Contact me for a free consultation at [email protected].
Subscribe to the low traffic mailing list to stay updated on Apex.