sqldata/sqldb.cpp
// Initialize database API once per process
Initialize database API once per process
Initialize database API once per process
int SqlDb::InitStaticApi(const char *conn, std::string &error)
{
	if(conn == NULL)
		return -1;
	int rc = 0;
	const char *cur = Str::SkipSpaces(conn);
	if(_strnicmp(cur, "mysql", 5) == 0 || _strnicmp(cur, "mariadb", 7) == 0)
	{
		SqlMysqlApi mysqlApi;
		mysqlApi.SetParameters(_parameters);
		mysqlApi.SetAppLog(_log);
		const char *conn = strchr(cur, ',');
		if(conn != NULL)
		{
			conn = Str::SkipSpaces(conn + 1);
			mysqlApi.SetConnectionString(conn);
		}
		if(_strnicmp(cur, "mariadb", 7) == 0)
			mysqlApi.SetSubType(SQLDATA_SUBTYPE_MARIADB);
		rc = mysqlApi.InitStatic();
		if(rc == -1)
			error = mysqlApi.GetNativeErrorText();
	}
	return rc;
}
int SqlDb :: InitStaticApi ( const char * conn , std :: string & error ) { if ( conn == NULL ) return -1 ; int rc = 0 ; const char * cur = Str :: SkipSpaces ( conn ) ; if ( _strnicmp ( cur , " " , 5 ) == 0 || _strnicmp ( cur , " " , 7 ) == 0 ) { SqlMysqlApi mysqlApi ; mysqlApi . SetParameters ( _parameters ) ; mysqlApi . SetAppLog ( _log ) ; const char * conn = strchr ( cur , ' ' ) ; if ( conn != NULL ) { conn = Str :: SkipSpaces ( conn + 1 ) ; mysqlApi . SetConnectionString ( conn ) ; } if ( _strnicmp ( cur , " " , 7 ) == 0 ) mysqlApi . SetSubType ( SQLDATA_SUBTYPE_MARIADB ) ; rc = mysqlApi . InitStatic ( ) ; if ( rc == -1 ) error = mysqlApi . GetNativeErrorText ( ) ; } return rc ; }
Initialize database API once per process
Initialize database API once per process
// Initialize MySQL C API // If API does not support static initialization 0 must be returned