sqldata/sqlmysqlapi.cpp
// Set version of the connected database
Set version of the connected database
Set version of the connected database
void SqlMysqlApi::SetVersion()
{
	const char *query = "SHOW VARIABLES LIKE 'VERSION%'";
	int rc = _mysql_query(&_mysql, query);
	if(rc != 0)
	{
		SetError();
		return;
	}
	MYSQL_RES *res = _mysql_use_result(&_mysql);
	if(res == NULL)
		return;
	_version.clear();
	int i = 0;
	bool more = true;
	while(more)
	{
		MYSQL_ROW row = _mysql_fetch_row(res);
		if(row == NULL || row[1] == NULL)
		{
			more = false;
			break;
		}
		if(i > 0)
			_version += " ";
		_version += row[1];
		if(row[0] != NULL && strcmp(row[0], "version") == 0)
		{
			sscanf(row[1], "%d.%d.%d", &_version_major, &_version_minor, &_version_release); 
		}
		i++;
	}
	_mysql_free_result(res);
}
void SqlMysqlApi :: SetVersion ( ) { const char * query = " " ; int rc = _mysql_query ( & _mysql , query ) ; if ( rc != 0 ) { SetError ( ) ; return ; } MYSQL_RES * res = _mysql_use_result ( & _mysql ) ; if ( res == NULL ) return ; _version . clear ( ) ; int i = 0 ; bool more = true ; while ( more ) { MYSQL_ROW row = _mysql_fetch_row ( res ) ; if ( row == NULL || row [ 1 ] == NULL ) { more = false ; break ; } if ( i > 0 ) _version += " " ; _version += row [ 1 ] ; if ( row [ 0 ] != NULL && strcmp ( row [ 0 ] , " " ) == 0 ) { sscanf ( row [ 1 ] , " " , & _version_major , & _version_minor , & _version_release ) ; } i ++ ; } _mysql_free_result ( res ) ; }
Set version of the connected database
Set version of the connected database
// Note: INFORMATION_SCHEMA.GLOBAL_VARIABLES is available since 5.1 only // Returns 4 rows and 2 columns: Variable_name and Value // 5.5.15	MySQL Community Server (GPL)	x86		Win32 // Execute the query // Error raised // Fetch the row // row[1] contains 2nd column as a null-terminated string // Set version numbers