FFDatabase

FFDatabase — Class for handling database connections.

Synopsis


#include <ff-database.h>


struct      FFDatabase;
struct      FFDatabaseClass;

FFDatabase* ff_database_new                 (void);

const gchar* ff_database_get_server_name    (FFDatabase *self);
void        ff_database_set_server_name     (FFDatabase *self,
                                             const gchar *server_name);
const gchar* ff_database_get_db_filename    (FFDatabase *self);
void        ff_database_set_db_filename     (FFDatabase *self,
                                             const gchar *file_name);
const gchar* ff_database_get_user_name      (FFDatabase *self);
void        ff_database_set_user_name       (FFDatabase *self,
                                             const gchar *user_name);
const gchar* ff_database_get_password       (FFDatabase *self);
void        ff_database_set_password        (FFDatabase *self,
                                             const gchar *password);
const gchar* ff_database_get_character_set  (FFDatabase *self);
void        ff_database_set_character_set   (FFDatabase *self,
                                             const gchar *char_set);
gint        ff_database_get_sql_dialect     (FFDatabase *self);
void        ff_database_set_sql_dialect     (FFDatabase *self,
                                             gshort dialect);
const gchar* ff_database_get_page_size      (FFDatabase *self);
void        ff_database_set_page_size       (FFDatabase *self,
                                             const gchar *page_size);
const isc_db_handle ff_database_get_handle  (FFDatabase *self);
gchar*      ff_database_get_server_version  (FFDatabase *self);

gboolean    ff_database_connect             (FFDatabase *self);
void        ff_database_disconnect          (FFDatabase *self);
gboolean    ff_database_is_connected        (FFDatabase *self);
gboolean    ff_database_create_db           (FFDatabase *self);
gboolean    ff_database_drop_db             (FFDatabase *self);
gboolean    ff_database_drop_db_named       (FFDatabase *self,
                                             gchar *db_full_path);


Description

Database connections are used to create connections with Firebird server providers.

Details

struct FFDatabase

struct FFDatabase;


struct FFDatabaseClass

struct FFDatabaseClass {

	void (* on_connect)			(FFDatabase *self, gpointer data);
	void (* on_disconnect)			(FFDatabase *self, gpointer data);
	void (* on_error)			(FFDatabase *self, FFError *error, gpointer data);
};

void (*on_connect) (FFDatabase *self, gpointer data)Triggered after database connection.
void (*on_disconnect) (FFDatabase *self, gpointer data)Triggered after database disconnection.
void (*on_error) (FFDatabase *self, FFError *error, gpointer data)Triggered after an error is reised.

ff_database_new ()

FFDatabase* ff_database_new                 (void);

Constructor for FFDatabase class.

Returns : A new FFDatabase object.

ff_database_get_server_name ()

const gchar* ff_database_get_server_name    (FFDatabase *self);

Get database server name.

self : A FFDatabase.
Returns : A string containing database server name.

ff_database_set_server_name ()

void        ff_database_set_server_name     (FFDatabase *self,
                                             const gchar *server_name);

Set database server name. Default is "localhost".

self : A FFDatabase.
server_name : A string containing server name or IP.

ff_database_get_db_filename ()

const gchar* ff_database_get_db_filename    (FFDatabase *self);

Get database file name and path.

self : A FFDatabase.
Returns : A string containing database file name and path.

ff_database_set_db_filename ()

void        ff_database_set_db_filename     (FFDatabase *self,
                                             const gchar *file_name);

Set database file name.

self : A FFDatabase.
file_name : A string containing file name and path od database.

ff_database_get_user_name ()

const gchar* ff_database_get_user_name      (FFDatabase *self);

Get database user name.

self : A FFDatabase.
Returns : A string containing the user name.

ff_database_set_user_name ()

void        ff_database_set_user_name       (FFDatabase *self,
                                             const gchar *user_name);

Set database user name.

self : A FFDatabase.
user_name : A string containing database user name.

ff_database_get_password ()

const gchar* ff_database_get_password       (FFDatabase *self);

Get database user password.

self : A FFDatabase.
Returns : A string containing user password.

ff_database_set_password ()

void        ff_database_set_password        (FFDatabase *self,
                                             const gchar *password);

Set database user password.

self : A FFDatabase.
password : A string containing user password.

ff_database_get_character_set ()

const gchar* ff_database_get_character_set  (FFDatabase *self);

Get database character set.

self : A FFDatabase.
Returns : A string containing database character ser.

ff_database_set_character_set ()

void        ff_database_set_character_set   (FFDatabase *self,
                                             const gchar *char_set);

Set database character set. Default is "NONE".

self : A FFDatabase
char_set : A string containing database character set.

ff_database_get_sql_dialect ()

gint        ff_database_get_sql_dialect     (FFDatabase *self);

Get database SQL dialect.

self : A FFDatabase.
Returns : Dialect number of database.

ff_database_set_sql_dialect ()

void        ff_database_set_sql_dialect     (FFDatabase *self,
                                             gshort dialect);

Set database SQL dialect. Default is 3.

self : A FFDatabase.
dialect : Dialect number of database.

ff_database_get_page_size ()

const gchar* ff_database_get_page_size      (FFDatabase *self);

Get database page size.

self : A FFDatabase.
Returns : A string containing database page size.

ff_database_set_page_size ()

void        ff_database_set_page_size       (FFDatabase *self,
                                             const gchar *page_size);

Set database page size. Default is "4096". Valid values for page_size are "1024", "2048", "4096" and "8192". This value is used when a new database is created.

self : A FFDatabase.
page_size : A string containing database page size.

ff_database_get_handle ()

const isc_db_handle ff_database_get_handle  (FFDatabase *self);

Get database handle.

self : A FFDatabase.
Returns : A database handle or NULL if database is not connected.

ff_database_get_server_version ()

gchar*      ff_database_get_server_version  (FFDatabase *self);

Get Firebird server version number

self : A FFDatabase.
Returns : A string containing server version, or NULL on error. String must be released by programmer after use.

ff_database_connect ()

gboolean    ff_database_connect             (FFDatabase *self);

Open connection to database.

self : A FFDatabase.
Returns : TRUE if successfully connected, or FALSE otherwise.

ff_database_disconnect ()

void        ff_database_disconnect          (FFDatabase *self);

Disconnect from database.

self : A FFDatabase.

ff_database_is_connected ()

gboolean    ff_database_is_connected        (FFDatabase *self);

Check if connection with database server is open.

self : A FFDatabase.
Returns : TRUE if database is connected, or FALSE otherwise.

ff_database_create_db ()

gboolean    ff_database_create_db           (FFDatabase *self);

Create a new empty database on server.

self : A FFDatabase.
Returns : TRUE if database was created successfully, or FALSE otherwise.

ff_database_drop_db ()

gboolean    ff_database_drop_db             (FFDatabase *self);

Drop current connected database from server.

self : A FFDatabase.
Returns : TRUE if database was successfully dropped, or FALSE otherwise.

ff_database_drop_db_named ()

gboolean    ff_database_drop_db_named       (FFDatabase *self,
                                             gchar *db_full_path);

Drop db_full_path database from server. Value of db_full_path must have following format: "server_name:/path/to/database/my_database.fdb" Examples: 192.168.0.1:/opt/databases/test_db.fdb server:/tmp/test_db.fdb

self : A FFDatabase.
db_full_path : A string containing database full path.
Returns : TRUE if database was successfully dropped, or FALSE otherwise.