|
|
connects to the SQL Server. Set set_host,set_user, set_password , set_tcp_port if necessary and then call connect.
~hk_connection ()
| ~hk_connection |
[virtual]
When the connection will be destroyed, the database created with new_database() and all its children will be destroyed
void set_host (const hk_string& h)
| set_host |
name of the host where the SQL Server is. Default is "localhost".
hk_string host (void)
| host |
void set_user (const hk_string& u)
| set_user |
user name for the SQL Server.
hk_string user (void)
| user |
void set_password (const hk_string& p)
| set_password |
password for the SQL Server
hk_string password (void)
| password |
void set_tcp_port (unsigned int t)
| set_tcp_port |
TCP Port number of the SQL Server. Default is 3306.
unsigned int tcp_port (void)
| tcp_port |
unsigned int default_tcp_port (void)
| default_tcp_port |
[const virtual]
returns the default tcp port of the the database driver;
bool connect (enum_interaction c=interactive)
| connect |
tries to connect to the SQL Server. If some information is missing (i.e. password) a dialog will ask for these values. You can set a GUI dependend dialog with set_passworddialog
Returns: true if connecting was successful, else false.
bool disconnect (void)
| disconnect |
disconnects from the SQL Server
Returns: true if successful.
bool is_connected (void)
| is_connected |
Returns: true if connect was successful
vector<hk_string>* dblist (void)
| dblist |
if connected it returns a hk_stringlist of all existing databases on the SQL Server.
The list will be created new every time you call this function.
So be careful. Never use i.e. for_each(dblist()->begin(),dblist()->end(),anyfunction)
Use instead:
list
hk_database* new_database (const hk_string& name="")
| new_database |
if you want to use a database on the SQL Server create a hk_database element with this class. For each connection you can define one database. If you define another one the old one will be destroyed.
bool rename_database (const hk_string& originalname, const hk_string& new_name)
| rename_database |
enum support_enum { SUPPORTS_AUTOINCCOLUMN=1, SUPPORTS_BOOLCOLUMN=2, SUPPORTS_DATECOLUMN=3, SUPPORTS_TIMECOLUMN=4, SUPPORTS_DATETIMECOLUMN=5, SUPPORTS_BINARYCOLUMN=6, SUPPORTS_MEMOCOLUMN=7, SUPPORTS_TIMESTAMPCOLUMN=8, SUPPORTS_SQL=100, SUPPORTS_TRANSACTIONS=101, SUPPORTS_REFERENTIALINTEGRITY=102, SUPPORTS_NEW_DATABASE=103, SUPPORTS_DELETE_DATABASE=104, SUPPORTS_NEW_TABLE=105, SUPPORTS_ALTER_TABLE=106, SUPPORTS_DELETE_TABLE=107, SUPPORTS_CREATE_INDEX=108, SUPPORTS_DELETE_INDEX=109, SUPPORTS_CHANGE_PASSWORD=110, SUPPORTS_RENAME_DATABASE=111, SUPPORTS_RENAME_TABLE=112 } | support_enum |
see also serversupports. Defines what abilities and fieldtypes a database driver supports
bool server_supports (support_enum)
| server_supports |
[virtual]
give information about the database server. See hk_definitions.h for details
enum need_enum { NEEDS_NOTHING=0, NEEDS_HOST=1, NEEDS_USERNAME=2, NEEDS_PASSWORD=3, NEEDS_SQLDELIMITER=4, NEEDS_PORT=5, NEEDS_DATABASENAME=6, NEEDS_BOOLEANEMULATION=7, NEEDS_NULL_TERMINATED_SQL=8 } | need_enum |
see server_needs
bool server_needs (need_enum)
| server_needs |
[virtual]
shows what information the database server needs (e.g. password).
void set_passworddialog (password_dialogtype*)
| set_passworddialog |
[static]
the passworddialog will be called from connect if necessary. You can define a GUI dependend dialog and set it with this function. What exactly is asked in the dialog is database driver dependend (i.e. the Mysql driver needs user, password, host and tcp_port)
bool create_database (const hk_string& dbase)
| create_database |
tries to create a new database. If successful it returns true else false
bool delete_database (const hk_string& dbase)
| delete_database |
tries to delete a database.
Parameters:
dbase | name of an existing database |
Returns: true if successful else flase
bool database_exists (const hk_string& databasename)
| database_exists |
checks whether a database exists
bool set_newpassword (const hk_string& newpassword)
| set_newpassword |
sets a new password at the SQL server.
Parameters:
newpassword | the new password |
Returns: true if successful else flase
void show_newpassworddialog (void)
| show_newpassworddialog |
shows a password dialog and sets the new password by calling set_newpassword If no passworddialog is set with set_newpassworddialog the necessary information will be queried at the standard output
void set_newpassworddialog (newpassword_dialogtype*)
| set_newpassworddialog |
[static]
It is possible to define a newpassworddialog, which will be shown when set_newpassword is called
bool show_passworddialog (void)
| show_passworddialog |
hk_string drivername (void)
| drivername |
[const virtual]
returns the name of the driver (e.g Mysql,Postgres etc.)
void set_booleanemulation (bool emulate)
| set_booleanemulation |
If the database does not have a native boolean type(like Mysql), but hk_classes should use one datatype to emulate, set this to true (default) else switch it off.
bool booleanemulation (void)
| booleanemulation |
[const]
hk_drivermanager* drivermanager (void)
| drivermanager |
bool copy_database (hk_database* fromdatabase,bool schema_and_data,bool copy_local_files,progress_dialogtype* progressdialog=NULL)
| copy_database |
copies whole databases
Parameters:
fromdatabase | the database that should be copied |
schema_and_data | if true both the table schemas will be created and the data will be copied, if false only the table will be created |
copy_local_files | if true queries,forms and reports will be also copied |
progressdialog | if set this function will be regularly called to show the progress |
hk_string last_servermessage (void)
| last_servermessage |
hk_connection (hk_drivermanager* c)
| hk_connection |
[protected]
bool p_connected | p_connected |
[protected]
bool driver_specific_connect (void)
| driver_specific_connect |
[protected virtual]
bool driver_specific_disconnect (void)
| driver_specific_disconnect |
[protected virtual]
bool driver_specific_rename_database (const hk_string& oldname,const hk_string& newname)
| driver_specific_rename_database |
[protected virtual]
vector<hk_string>* driver_specific_dblist (void)
| driver_specific_dblist |
[protected virtual]
hk_database* driver_specific_new_database (void)
| driver_specific_new_database |
[protected virtual]
bool driver_specific_new_password (const hk_string&)
| driver_specific_new_password |
[protected virtual]
void db_remove (hk_database* d)
| db_remove |
[protected]
hk_string sqldelimiter (void)
| sqldelimiter |
[protected]
void inform_databases_connect (void)
| inform_databases_connect |
[protected]
void inform_databases_disconnect (void)
| inform_databases_disconnect |
[protected]
vector<hk_string> p_databaselist | p_databaselist |
[protected]
void savedata (ostream& s)
| savedata |
[protected virtual]
saves the tags
Reimplemented from hk_class.
void loaddata (const hk_string& definition)
| loaddata |
[protected virtual]
load the tags
Reimplemented from hk_class.
void set_last_servermessage (const hk_string& m)
| set_last_servermessage |
[protected]
hk_database* database (void)
| database |
[protected]