Main Page   Data Structures   File List   Data Fields  

CMyMySQLPPConnection Class Reference

#include <MyMySQLPPConnection.h>


Detailed Description

The connection object represents the connection to a mysql server and is used to perform queries.

Definition at line 31 of file MyMySQLPPConnection.h.

Public Member Functions

 CMyMySQLPPConnection (void)
 Class constructor.

 ~CMyMySQLPPConnection (void)
 Class destructor.

BOOL Connect (const char *host, const char *user, const char *password, const char *database=NULL, unsigned int port=3306, const char *unix_socket=NULL, unsigned int client_flag=0)
 Connects to server.

void Close (void)
 Disconnects from server.

BOOL Ping (void)
 Checks if server is still alive.

char * GetClientInfo (void)
 Returns a string that represents the client library version.

char * GetHostInfo (void)
 Returns a string describing the type of connection in use.

unsigned int GetProtocolInfo (void)
 Returns the protocol version used by current connection.

char * GetServerInfo (void)
 Returns a string that represents the server version number.

__int64 AffectedRows (void)
 Returns the number of rows changed by the last UPDATE, deleted by the last DELETE or inserted by the last INSERT statement.

BOOL ChangeUser (const char *user, const char *password, const char *db)
 Changes the user and causes the database specified by db to become the default (current) database.

const char * CharacterSetName (void)
 Returns the default character set for the current connection.

unsigned int ErrorNumber (void)
 Returns the error code for the most recently invoked API function that can succeed or fail.

char * Error (void)
 Returns the error message for the most recently invoked API function that can succeed or fail.

__int64 InsertID (void)
 Returns the ID generated for an AUTO_INCREMENT column by the previous query.

char * Info (void)
 Retrieves a string providing information about the most recently executed query.

BOOL Kill (unsigned long pid)
 Asks the server to kill the thread specified by pid.

BOOL ListDatabases (CMyMySQLPPResult *result, const char *wild=NULL)
 Returns a result set consisting of database names on the server that match the simple regular expression specified by the wild parameter.

BOOL ListFields (CMyMySQLPPResult *result, const char *table, const char *wild)
 Returns a result set consisting of field names in the given table that match the simple regular expression specified by the wild parameter.

BOOL DropDatabase (const char *db)
 Drops the database named by the db parameter.

BOOL ListProcesses (CMyMySQLPPResult *result)
 Returns a result set describing the current server threads.

BOOL ListTables (CMyMySQLPPResult *result, const char *wild)
 Returns a result set consisting of table names in the current database that match the simple regular expression specified by the wild parameter.

BOOL Options (enum mysql_option option, const char *arg)
 Can be used to set extra connect options and affect behaviour for a connection.

BOOL Query (const char *query)
 Executes the SQL query pointed to by the null-terminated string query. Cannot be used for queries that contain binary data - use RealQuery() instead.

unsigned long RealEscape (char *to, char *from, unsigned long length)
 This function is used to create a legal SQL string that you can use in a SQL statement.

BOOL RealQuery (const char *query, unsigned long length)
 Executes the SQL query pointed to by query, which should be a string length bytes long - binary safe version of Query().

BOOL Reload (void)
 Asks the MySQL server to reload the grant tables. The connected user must have the RELOAD privilege.

BOOL SelectDatabase (const char *db)
 Causes the database specified by db to become the default (current) database on the connection.

BOOL Shutdown (void)
 Asks the database server to shut down. The connected user must have SHUTDOWN privileges.

char * Status (void)
 Returns a character string containing information similar to that provided by the mysqladmin status command.

BOOL StoreResult (CMyMySQLPPResult *result)
 Reads the entire result of a query.

unsigned long ThreadID (void)
 Returns the thread ID of current connection.

BOOL UseResult (CMyMySQLPPResult *result)
 Initiates a result set retrieval but does not actually read the result set into the client like StoreResult() does.


Constructor & Destructor Documentation

CMyMySQLPPConnection::CMyMySQLPPConnection void   
 

Class constructor.

Definition at line 34 of file MyMySQLPPConnection.cpp.

CMyMySQLPPConnection::~CMyMySQLPPConnection void   
 

Class destructor.

Definition at line 40 of file MyMySQLPPConnection.cpp.

References Close().


Member Function Documentation

__int64 CMyMySQLPPConnection::AffectedRows void   
 

Returns the number of rows changed by the last UPDATE, deleted by the last DELETE or inserted by the last INSERT statement.

Returns:
Number of rows affected by last UPDATE, DELETE or INSERT.

Definition at line 128 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::ChangeUser const char *    user,
const char *    password,
const char *    db
 

Changes the user and causes the database specified by db to become the default (current) database.

Parameters:
user New user name
password Password for this new user
db New default database or NULL if you don't want a default database to be selected
Returns:
TRUE on success, FALSE on failure

Definition at line 141 of file MyMySQLPPConnection.cpp.

const char * CMyMySQLPPConnection::CharacterSetName void   
 

Returns the default character set for the current connection.

Returns:
Name of current character set or NULL if no connection persists.

Definition at line 151 of file MyMySQLPPConnection.cpp.

void CMyMySQLPPConnection::Close void   
 

Disconnects from server.

Definition at line 70 of file MyMySQLPPConnection.cpp.

Referenced by ~CMyMySQLPPConnection().

BOOL CMyMySQLPPConnection::Connect const char *    host,
const char *    user,
const char *    password,
const char *    database = NULL,
unsigned int    port = 3306,
const char *    unix_socket = NULL,
unsigned int    client_flag = 0
 

Connects to server.

Parameters:
host Hostname of server
user Username for authentication
password Password for authentication
database Default database or NULL if you don't want a default database to be selected
port Port of MySQL server. Default port is 3306
unix_socket Unix socket to be used or NULL if you don't want a unix socket.
client_flag Additional connection parameters. Default is 0. See MySQL documentation
Returns:
TRUE on success, FALSE on failure.

Definition at line 55 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::DropDatabase const char *    db
 

Drops the database named by the db parameter.

Parameters:
db Database to drop
Returns:
TRUE on success, FALSE on failure

Definition at line 248 of file MyMySQLPPConnection.cpp.

char * CMyMySQLPPConnection::Error void   
 

Returns the error message for the most recently invoked API function that can succeed or fail.

Returns:
Error string describing last failure

Definition at line 171 of file MyMySQLPPConnection.cpp.

unsigned int CMyMySQLPPConnection::ErrorNumber void   
 

Returns the error code for the most recently invoked API function that can succeed or fail.

Returns:
Error number describing last failure

Definition at line 161 of file MyMySQLPPConnection.cpp.

Referenced by StoreResult().

char * CMyMySQLPPConnection::GetClientInfo void   
 

Returns a string that represents the client library version.

Returns:
Client version

Definition at line 90 of file MyMySQLPPConnection.cpp.

char * CMyMySQLPPConnection::GetHostInfo void   
 

Returns a string describing the type of connection in use.

Returns:
Type of connection or NULL if no connection persists

Definition at line 98 of file MyMySQLPPConnection.cpp.

unsigned int CMyMySQLPPConnection::GetProtocolInfo void   
 

Returns the protocol version used by current connection.

Returns:
Protocol version NULL if no connection persists.

Definition at line 108 of file MyMySQLPPConnection.cpp.

char * CMyMySQLPPConnection::GetServerInfo void   
 

Returns a string that represents the server version number.

Returns:
Server version or NULL if no connection persists

Definition at line 118 of file MyMySQLPPConnection.cpp.

char * CMyMySQLPPConnection::Info void   
 

Retrieves a string providing information about the most recently executed query.

Returns:
Information about the last query or NULL if no connection persists

Definition at line 191 of file MyMySQLPPConnection.cpp.

__int64 CMyMySQLPPConnection::InsertID void   
 

Returns the ID generated for an AUTO_INCREMENT column by the previous query.

Returns:
ID generated for an AUTO_INCREMENT column by the previous query.

Definition at line 181 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::Kill unsigned long    pid
 

Asks the server to kill the thread specified by pid.

Parameters:
pid PID to kill
Returns:
TRUE on success, FALSE on failure

Definition at line 202 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::ListDatabases CMyMySQLPPResult   result,
const char *    wild = NULL
 

Returns a result set consisting of database names on the server that match the simple regular expression specified by the wild parameter.

Parameters:
result CMyMySQLPPResult to store result
wild Simple regular expression or NULL to list all databases
Returns:
TRUE on success, FALSE on failure

Definition at line 214 of file MyMySQLPPConnection.cpp.

References CMyMySQLPPResult::Attach(), and CMyMySQLPPResult::Free().

BOOL CMyMySQLPPConnection::ListFields CMyMySQLPPResult   result,
const char *    table,
const char *    wild
 

Returns a result set consisting of field names in the given table that match the simple regular expression specified by the wild parameter.

Parameters:
result CMyMySQLPPResult to store result
table Table
wild Simple regular expression or NULL to list all fields
Returns:
TRUE on success, FALSE on failure

Definition at line 232 of file MyMySQLPPConnection.cpp.

References CMyMySQLPPResult::Attach(), and CMyMySQLPPResult::Free().

BOOL CMyMySQLPPConnection::ListProcesses CMyMySQLPPResult   result
 

Returns a result set describing the current server threads.

Parameters:
result CMyMySQLPPResult to store result
Returns:
TRUE on success, FALSE on failure

Definition at line 259 of file MyMySQLPPConnection.cpp.

References CMyMySQLPPResult::Attach(), and CMyMySQLPPResult::Free().

BOOL CMyMySQLPPConnection::ListTables CMyMySQLPPResult   result,
const char *    wild
 

Returns a result set consisting of table names in the current database that match the simple regular expression specified by the wild parameter.

Parameters:
result CMyMySQLPPResult to store result
wild Simple regular expression or NULL to list all tables
Returns:
TRUE on success, FALSE on failure

Definition at line 276 of file MyMySQLPPConnection.cpp.

References CMyMySQLPPResult::Attach(), and CMyMySQLPPResult::Free().

BOOL CMyMySQLPPConnection::Options enum mysql_option    option,
const char *    arg
 

Can be used to set extra connect options and affect behaviour for a connection.

Parameters:
option Option to set, see MySQL documentation
arg Argument for that option, see MySQL documentation
Returns:
TRUE on success, FALSE on failure

Definition at line 293 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::Ping void   
 

Checks if server is still alive.

Returns:
TRUE if server is alive or FALSE if if is dead

Definition at line 80 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::Query const char *    query
 

Executes the SQL query pointed to by the null-terminated string query. Cannot be used for queries that contain binary data - use RealQuery() instead.

Parameters:
query Query to execute
Returns:
TRUE if the query has been executed (so you must call StoreResult or UseResult) or FALSE on failure

Definition at line 304 of file MyMySQLPPConnection.cpp.

unsigned long CMyMySQLPPConnection::RealEscape char *    to,
char *    from,
unsigned long    length
 

This function is used to create a legal SQL string that you can use in a SQL statement.

Parameters:
to String to store escaped input with space for at least 2*length(from)+1 characters !
from Input string
length Length of input
Returns:
Number of bytes placed into 'to'

Definition at line 317 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::RealQuery const char *    query,
unsigned long    length
 

Executes the SQL query pointed to by query, which should be a string length bytes long - binary safe version of Query().

Parameters:
query Query to execute
length Length of that query
Returns:
TRUE if the query has been executed (so you must call StoreResult or UseResult) or FALSE on failure

Definition at line 329 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::Reload void   
 

Asks the MySQL server to reload the grant tables. The connected user must have the RELOAD privilege.

Returns:
TRUE if the grant tables have been reloaded or FALSE on failure.

Definition at line 339 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::SelectDatabase const char *    db
 

Causes the database specified by db to become the default (current) database on the connection.

Parameters:
db The new default database
Returns:
TRUE if the database has been selected, FALSE on failure

Definition at line 350 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::Shutdown void   
 

Asks the database server to shut down. The connected user must have SHUTDOWN privileges.

Returns:
TRUE if the server is beeing shut down or FALSE on failure

Definition at line 360 of file MyMySQLPPConnection.cpp.

char * CMyMySQLPPConnection::Status void   
 

Returns a character string containing information similar to that provided by the mysqladmin status command.

Returns:
General status of the mysql server

Definition at line 370 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::StoreResult CMyMySQLPPResult   result
 

Reads the entire result of a query.

Parameters:
result CMyMySQLPPResult to store result set in
Returns:
TRUE if the result has been completely stored or FALSE on failure
Error occured (res == NULL) && (ErrorNumber == 0): Result ok, but no rows

Definition at line 381 of file MyMySQLPPConnection.cpp.

References CMyMySQLPPResult::Attach(), ErrorNumber(), and CMyMySQLPPResult::Free().

unsigned long CMyMySQLPPConnection::ThreadID void   
 

Returns the thread ID of current connection.

Returns:
Thread ID of current connection, may change if you reconnect !

Definition at line 398 of file MyMySQLPPConnection.cpp.

BOOL CMyMySQLPPConnection::UseResult CMyMySQLPPResult   result
 

Initiates a result set retrieval but does not actually read the result set into the client like StoreResult() does.

Parameters:
result CMyMySQLPPResult to store result in
Returns:
TRUE if that result is used to store the incoming result set, FALSE on failure

Definition at line 409 of file MyMySQLPPConnection.cpp.

References CMyMySQLPPResult::Attach(), and CMyMySQLPPResult::Free().


The documentation for this class was generated from the following files:
Generated on Thu Feb 20 16:15:59 2003 for MyMySQL++ by doxygen1.3-rc3