diff --git a/harbour/contrib/mysql/mysql.c b/harbour/contrib/mysql/mysql.c index e8fb5dff9c..eba7771691 100644 --- a/harbour/contrib/mysql/mysql.c +++ b/harbour/contrib/mysql/mysql.c @@ -343,14 +343,23 @@ HB_FUNC(SQLSRVINFO) _retc( mysql_get_server_info( (MYSQL *)_parnl(1) ) ); } +#ifdef __GNUC__ +int filelength( int handle ) +{ + int nEnd = hb_fsSeek( handle, 0 , 2 ); + int nStart = hb_fsSeek( handle , 0 , 0 ); + return nEnd - nStart; +} +#endif + char *filetoBuff(char *f,char *s) { -/* int i=0; */ + int i; - int fh= hb_fsOpen((BYTE*)s,2); - i=hb_fsReadLarge(fh,(BYTE*)f,filelength(fh)); + int fh = hb_fsOpen( ( BYTE * ) s , 2 ); + i = hb_fsReadLarge( fh , ( BYTE * ) f , filelength( fh ) ); f[ i ] = '\0'; - hb_fsClose(fh); + hb_fsClose( fh ); return f ; } diff --git a/harbour/contrib/mysql/tmysql.prg b/harbour/contrib/mysql/tmysql.prg index de05b20669..587eb32ac6 100644 --- a/harbour/contrib/mysql/tmysql.prg +++ b/harbour/contrib/mysql/tmysql.prg @@ -743,6 +743,7 @@ CLASS TMySQLServer METHOD NetErr() INLINE ::lError // Returns .T. if something went wrong METHOD Error() // Returns textual description of last error + METHOD CreateDatabase( cDataBase ) // Create an New Mysql Database ENDCLASS @@ -780,6 +781,16 @@ METHOD SelectDB(cDBName) CLASS TMySQLServer return .F. +METHOD CreateDatabase ( cDataBase ) CLASS TMySQLServer + local cCreateQuery := "CREATE DATABASE "+ lower(cDatabase) + + if sqlQuery(::nSocket, cCreateQuery) == 0 + return .T. + endif + +return .F. + + // NOTE: OS/2 port of MySQL is picky about table names, that is if you create a table with // an upper case name you cannot alter it (for example) using a lower case name, this violates // OS/2 case insensibility about names