bool Database::Connected() { OPENDB *odb = grabdb(); if (!odb) { return false; } freedb(odb); return true; }
bool sqlitedatabase::Connected() { SqliteDB * odb = grabdb(); if(!odb) { return false; } freedb(odb); return true; }
bool Database::Connected() { OPENDB *odb = grabdb(); if (!odb) { return false; } int ping_result = mysql_ping(&odb -> mysql); if (ping_result) { error("mysql_ping() failed"); } freedb(odb); return ping_result ? false : true; }
bool sql_connection_c::connected() { OPENDB *odb = grabdb(); if (!odb) { return false; } int ping_result = mysql_ping(&odb->mysql); if (ping_result) { printf("sql_connection_c::connected() - mysql_ping() failed\n"); } freedb(odb); return ping_result ? false : true; }
void sql_connection_c::connect( char *__database, char *__host, char *__user, char *__password ) { host = new char[ strlen( __host ) + 1 ]; strcpy( host, __host ); if ( __user ) { user = new char[ strlen( __user ) + 1 ]; strcpy( user, __user ); } if ( __password ) { password = new char[ strlen( __password ) + 1 ]; strcpy( password, __password ); } database = new char[ strlen( __database ) + 1 ]; strcpy( database, __database ); freedb( grabdb() ); //// open one connection }
void sql_connection_c::connect(char *__database, char *__host, char *__user, char *__password) { disconnect(); if (!__database || !__host) { printf("sql_connection_c::connect - Parameter(s) are null\n"); return; } // Assume the default port portn = 3306; char * host_buff = 0; char * host_tmp = 0; char * port_tmp = 0; if (host) { delete [] host; } if (database) { delete [] database; } if (user) { delete [] user; user = 0; } if (password) { delete [] password; password = 0; } // Seperate the host from the port host_buff = new char[strlen(__host) + 1]; strcpy(host_buff, __host); host_tmp = strtok(host_buff, ":"); port_tmp = strtok(NULL, ""); if (!host_tmp) { printf("sql_connection_c::connect - Invalid host: %s\n",__host); return; } if (!port_tmp) { portn = atoi(port_tmp); } host = new char[strlen(host_tmp) + 1]; strcpy(host, host_tmp); if (host_buff) { delete [] host_buff; } database = new char[strlen(__database) + 1]; strcpy(database, __database); if (__user) { user = new char[strlen(__user) + 1]; strcpy(user, __user); } if (__password) { password = new char[strlen(__password) + 1]; strcpy(password, __password); } // Open a connection freedb(grabdb()); }