#include <MySQLDatabase.hpp>
Inheritance diagram for Ionflux::Tools::MySQLDatabase:
Public Member Functions | |
MySQLDatabase () | |
Constructor. | |
MySQLDatabase (const DatabaseConfig &initConfig) | |
Constructor. | |
virtual | ~MySQLDatabase () |
Destructor. | |
virtual void | setConfig (const DatabaseConfig &newConfig) |
Set database configuration. | |
virtual void | setConfig (Ionflux::Tools::Node &newConfig) |
Set database configuration. | |
virtual DatabaseConfig | getConfig () |
Get database configuration. | |
virtual bool | connect () |
Connect to database. | |
virtual void | close () |
Close database connection. | |
virtual bool | query (const std::string &command) |
Execute database query. | |
virtual bool | listTables (DbTables &tables, const std::string &pattern="") |
List tables. | |
virtual bool | listColumns (DbColumns &columns, const std::string &table) |
List columns. | |
virtual unsigned int | getNumRows (const std::string &table) |
Get number of rows. | |
virtual unsigned int | getNumRows () |
Get number of rows returned. | |
virtual unsigned int | getNumAffectedRows () |
Get number of rows affected. | |
virtual bool | fetchRow (DbRow &row) |
Get a result row. | |
virtual bool | fetchRowMap (DbRowMap &rowMap) |
Get a result row as a map. | |
virtual bool | fetchRowTree (Node &rowNode) |
Get a result row as a tree. | |
virtual bool | fetchResult (DbResult &result) |
Get a complete result. | |
virtual bool | fetchResultMap (DbResultMap &resultMap) |
Get a complete result as a map. | |
virtual bool | fetchResultTree (Node &resultNode, int nodeOrder) |
Get a complete result as a tree. | |
virtual std::string | sqlEscape (const std::string &source) |
Escape string. | |
virtual bool | validateTable (const std::string &tableName, const std::string &createTemplate="", Node *createConfig=0) |
Validate existence of table. | |
virtual DatabaseError | getError () |
Get error. | |
Static Public Attributes | |
static const std::string | DEFAULT_SERVER = "localhost" |
Default server. | |
static const unsigned int | DEFAULT_PORT = 3306 |
Default port. | |
static const std::string | DEFAULT_USERNAME = "anonymous" |
Default username. | |
static const std::string | DEFAULT_PASSWORD = "" |
Default password. | |
static const std::string | DEFAULT_DATABASE = "test" |
Default database. | |
static const MySQLDatabaseClassInfo | mySQLDatabaseClassInfo |
Class information instance. | |
static const ClassInfo * | CLASS_INFO |
Class information. | |
Protected Member Functions | |
void | freeResult () |
Free the result. | |
Protected Attributes | |
DatabaseConfig | config |
Database configuration. | |
MYSQL * | mysql |
MySQL Connection handle. | |
MYSQL_RES * | queryResult |
MySQL result handle. | |
unsigned int | numRows |
Rows in result set. | |
unsigned int | numFields |
Fields in result set. | |
int | numAffectedRows |
Affected rows. | |
DatabaseError | lastError |
Error. |
An Interface to MySQL databases. After initializing the object with a suitable database configuration, you can immediately perform database operations (the interface will automatically establish a connection on demand). You can retrieve query results either as nested STL-style containers, or as a Node object.
|
Constructor. Construct new MySQLDatabase object. |
|
Constructor. Construct new MySQLDatabase object. |
|
Destructor. Destruct MySQLDatabase object. |
|
Close database connection.
Implements Ionflux::Tools::Database. |
|
Connect to database. Establish a database connection.
Implements Ionflux::Tools::Database. |
|
Get a complete result. Initializes a DbResult to contain all result rows.
Implements Ionflux::Tools::Database. |
|
Get a complete result as a map. Initializes a DbResultMap to contain all result rows as maps. Use this to get a complete result as maps.
Implements Ionflux::Tools::Database. |
|
Get a complete result as a tree. Initializes a tree node to contain all result rows. Use this to get a complete result as a tree. You can specify either Database::NODE_ORDER_ROWS, Database::NODE_ORDER_NAMED_FIELDS, or Database::NODE_ORDER_COLUMNS as 'nodeOrder'. In row order mode, each node on the first level represents a row, and each data entry contains field data. The first node contains the field names as data entries. In named field order mode, each node on the first level represents a row. Each node on the second level contains field data and has its name set to the field name. In column order mode, each node on the first level represents a column and has its name set to the corresponding field name. Each data entry contains field data for a row.
Implements Ionflux::Tools::Database. |
|
Get a result row. Initializes a DbRow to contain the fields of a result row.
Implements Ionflux::Tools::Database. |
|
Get a result row as a map. Initializes a DbRowMap to contain the fields of a result row. Use this to get a result row as a map (associative array).
Implements Ionflux::Tools::Database. |
|
Get a result row as a tree. Initializes a tree node to contain the fields of a result row. Use this to get a result row as a tree.
Implements Ionflux::Tools::Database. |
|
Free the result.
|
|
Get database configuration. Get the database configuration currently used.
Implements Ionflux::Tools::Database. |
|
Get error. Get the last error.
Implements Ionflux::Tools::Database. |
|
Get number of rows affected. Get the number of rows affected by the previous query.
Implements Ionflux::Tools::Database. |
|
Get number of rows returned. Get the number of rows returned by the previous query.
Implements Ionflux::Tools::Database. |
|
Get number of rows. Get the number of rows for the specified table.
Implements Ionflux::Tools::Database. |
|
List columns. Fetches a list of columns for the specified table.
Implements Ionflux::Tools::Database. |
|
List tables. Fetches a list of tables from the current database that match the specified pattern. Pass an empty string to match all tables.
Implements Ionflux::Tools::Database. |
|
Execute database query. Execute a database query.
Implements Ionflux::Tools::Database. |
|
Set database configuration. Set configuration options for the database.
Implements Ionflux::Tools::Database. |
|
Set database configuration. Set configuration options for the database.
Implements Ionflux::Tools::Database. |
|
Escape string. Escapes a string so it represents a valid SQL string.
Implements Ionflux::Tools::Database. |
|
Validate existence of table. Validate the existence of the table with the specified name. If the table does not exist and a create template is specified, try to create the table.
Implements Ionflux::Tools::Database. |
|
Initial value: Class information.
Reimplemented from Ionflux::Tools::Database. |
|
Database configuration.
|
|
Default database.
|
|
Default password.
|
|
Default port.
|
|
Default server.
|
|
Default username.
|
|
Error.
|
|
MySQL Connection handle.
|
|
Class information instance.
|
|
Affected rows.
|
|
Fields in result set.
|
|
Rows in result set.
|
|
MySQL result handle.
|