2009-03-19 01:14 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* contrib/hbmysql/mysql.c
* contrib/hbmysql/tmysql.prg
* Renamed all functions to standard mysql equivalents.
Please update your code and turn off old function
names with -DHB_MYSQL_LEGACY_LEVEL_OFF to test for
success. Legacy function names will be removed from
Harbour in the next release. This move allows to use
hbmysql and hbodbc in the same app.
SQLAND() has to be replaced with HB_BITAND(), be aware
that latter will RTE when non-numeric var is passed,
while SQLAND() was silently ignoring it.
Changed functions names:
SQLVERSION() => mysql_get_server_version()
SQLCONNECT() => mysql_real_connect()
SQLCLOSE() => mysql_close()
SQLCOMMIT() => mysql_commit()
SQLROLLBACK() => mysql_rollback()
SQLSELECTD() => mysql_select_db()
SQLQUERY() => mysql_query()
SQLSTORER() => mysql_store_result()
SQLUSERES() => mysql_use_result()
SQLFREER() => mysql_free_result()
SQLFETCHR() => mysql_fetch_row()
SQLDATAS() => mysql_data_seek()
SQLNROWS() => mysql_num_rows()
SQLFETCHF() => mysql_fetch_field()
SQLFSEEK() => mysql_field_seek()
SQLNUMFI() => mysql_num_fields()
SQLFICOU() => mysql_field_count()
SQLLISTF() => mysql_list_fields()
SQLGETERR() => mysql_error()
SQLLISTDB() => mysql_list_dbs()
SQLLISTTBL() => mysql_list_tables()
SQLAFFROWS() => mysql_affected_rows()
SQLHOSTINFO() => mysql_get_host_info()
SQLSRVINFO() => mysql_get_server_info()
DATATOSQL() => mysql_escape_string()
FILETOSQLBINARY() => mysql_escape_string_from_file()
SQLAND() => hb_bitAnd()
* source/vm/maindll.c
* source/vm/maindllh.c
* source/vm/maindllp.c
* contrib/hbodbc/odbc.c
* Minor formatting.
This commit is contained in:
@@ -8,6 +8,53 @@
|
||||
2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2009-03-19 01:14 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
|
||||
* contrib/hbmysql/mysql.c
|
||||
* contrib/hbmysql/tmysql.prg
|
||||
* Renamed all functions to standard mysql equivalents.
|
||||
Please update your code and turn off old function
|
||||
names with -DHB_MYSQL_LEGACY_LEVEL_OFF to test for
|
||||
success. Legacy function names will be removed from
|
||||
Harbour in the next release. This move allows to use
|
||||
hbmysql and hbodbc in the same app.
|
||||
SQLAND() has to be replaced with HB_BITAND(), be aware
|
||||
that latter will RTE when non-numeric var is passed,
|
||||
while SQLAND() was silently ignoring it.
|
||||
Changed functions names:
|
||||
SQLVERSION() => mysql_get_server_version()
|
||||
SQLCONNECT() => mysql_real_connect()
|
||||
SQLCLOSE() => mysql_close()
|
||||
SQLCOMMIT() => mysql_commit()
|
||||
SQLROLLBACK() => mysql_rollback()
|
||||
SQLSELECTD() => mysql_select_db()
|
||||
SQLQUERY() => mysql_query()
|
||||
SQLSTORER() => mysql_store_result()
|
||||
SQLUSERES() => mysql_use_result()
|
||||
SQLFREER() => mysql_free_result()
|
||||
SQLFETCHR() => mysql_fetch_row()
|
||||
SQLDATAS() => mysql_data_seek()
|
||||
SQLNROWS() => mysql_num_rows()
|
||||
SQLFETCHF() => mysql_fetch_field()
|
||||
SQLFSEEK() => mysql_field_seek()
|
||||
SQLNUMFI() => mysql_num_fields()
|
||||
SQLFICOU() => mysql_field_count()
|
||||
SQLLISTF() => mysql_list_fields()
|
||||
SQLGETERR() => mysql_error()
|
||||
SQLLISTDB() => mysql_list_dbs()
|
||||
SQLLISTTBL() => mysql_list_tables()
|
||||
SQLAFFROWS() => mysql_affected_rows()
|
||||
SQLHOSTINFO() => mysql_get_host_info()
|
||||
SQLSRVINFO() => mysql_get_server_info()
|
||||
DATATOSQL() => mysql_escape_string()
|
||||
FILETOSQLBINARY() => mysql_escape_string_from_file()
|
||||
SQLAND() => hb_bitAnd()
|
||||
|
||||
* source/vm/maindll.c
|
||||
* source/vm/maindllh.c
|
||||
* source/vm/maindllp.c
|
||||
* contrib/hbodbc/odbc.c
|
||||
* Minor formatting.
|
||||
|
||||
2009-03-18 20:17 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
|
||||
* source/vm/Makefile
|
||||
+ source/vm/maindllp
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
#include "mysql.h"
|
||||
|
||||
/* NOTE: OS/2 EMX port of MySQL needs libmysqlclient.a from 3.21.33b build which has st and mt
|
||||
versions of client library. I'm using ST version since harbour is single threaded.
|
||||
versions of client library. I'm using ST version since harbour is single threaded.
|
||||
You need also .h files from same distribution. */
|
||||
|
||||
/* TODO: Use hb_retptrGC() */
|
||||
@@ -78,7 +78,7 @@
|
||||
#define HB_PARPTR( n ) hb_parptr( n )
|
||||
#define HB_RETPTR( n ) hb_retptr( n )
|
||||
|
||||
HB_FUNC( SQLVERSION ) /* long mysql_get_server_version( MYSQL * ) */
|
||||
HB_FUNC( MYSQL_GET_SERVER_VERSION ) /* long mysql_get_server_version( MYSQL * ) */
|
||||
{
|
||||
#if MYSQL_VERSION_ID > 32399
|
||||
hb_retnl( ( long ) mysql_get_server_version( ( MYSQL * ) HB_PARPTR( 1 ) ) );
|
||||
@@ -96,7 +96,7 @@ HB_FUNC( SQLVERSION ) /* long mysql_get_server_version( MYSQL * ) */
|
||||
#endif
|
||||
}
|
||||
|
||||
HB_FUNC( SQLCONNECT ) /* MYSQL *mysql_real_connect(MYSQL*, char * host, char * user, char * password, char * db, uint port, char *, uint flags) */
|
||||
HB_FUNC( MYSQL_REAL_CONNECT ) /* MYSQL * mysql_real_connect( MYSQL *, char * host, char * user, char * password, char * db, uint port, char *, uint flags ) */
|
||||
{
|
||||
const char * szHost = hb_parc( 1 );
|
||||
const char * szUser = hb_parc( 2 );
|
||||
@@ -126,12 +126,12 @@ HB_FUNC( SQLCONNECT ) /* MYSQL *mysql_real_connect(MYSQL*, char * host, char * u
|
||||
#endif
|
||||
}
|
||||
|
||||
HB_FUNC( SQLCLOSE ) /* void mysql_close(MYSQL *mysql) */
|
||||
HB_FUNC( MYSQL_CLOSE ) /* void mysql_close( MYSQL * mysql ) */
|
||||
{
|
||||
mysql_close( ( MYSQL * ) HB_PARPTR( 1 ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLCOMMIT ) /* bool mysql_commit(MYSQL *mysql) */
|
||||
HB_FUNC( MYSQL_COMMIT ) /* bool mysql_commit( MYSQL * mysql ) */
|
||||
{
|
||||
#if MYSQL_VERSION_ID >= 40100
|
||||
hb_retnl( ( long ) mysql_commit( ( MYSQL * ) HB_PARPTR( 1 ) ) );
|
||||
@@ -140,7 +140,7 @@ HB_FUNC( SQLCOMMIT ) /* bool mysql_commit(MYSQL *mysql) */
|
||||
#endif
|
||||
}
|
||||
|
||||
HB_FUNC( SQLROLLBACK ) /* bool mysql_rollback(MYSQL *mysql) */
|
||||
HB_FUNC( MYSQL_ROLLBACK ) /* bool mysql_rollback( MYSQL * mysql ) */
|
||||
{
|
||||
#if MYSQL_VERSION_ID >= 40100
|
||||
hb_retnl( ( long ) mysql_rollback( ( MYSQL * ) HB_PARPTR( 1 ) ) );
|
||||
@@ -149,32 +149,32 @@ HB_FUNC( SQLROLLBACK ) /* bool mysql_rollback(MYSQL *mysql) */
|
||||
#endif
|
||||
}
|
||||
|
||||
HB_FUNC( SQLSELECTD ) /* int mysql_select_db(MYSQL *, char *) */
|
||||
HB_FUNC( MYSQL_SELECT_DB ) /* int mysql_select_db( MYSQL *, char * ) */
|
||||
{
|
||||
hb_retnl( ( long ) mysql_select_db( ( MYSQL * ) HB_PARPTR( 1 ), ( const char * ) hb_parc( 2 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLQUERY ) /* int mysql_query(MYSQL *, char *) */
|
||||
HB_FUNC( MYSQL_QUERY ) /* int mysql_query( MYSQL *, char * ) */
|
||||
{
|
||||
hb_retnl( ( long ) mysql_query( ( MYSQL * ) HB_PARPTR( 1 ), hb_parc( 2 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLSTORER ) /* MYSQL_RES *mysql_store_result( MYSQL * ) */
|
||||
HB_FUNC( MYSQL_STORE_RESULT ) /* MYSQL_RES * mysql_store_result( MYSQL * ) */
|
||||
{
|
||||
HB_RETPTR( ( void * ) mysql_store_result( ( MYSQL * ) HB_PARPTR( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLUSERES ) /* MYSQL_RES *mysql_use_result( MYSQL * ) */
|
||||
HB_FUNC( MYSQL_USE_RESULT ) /* MYSQL_RES * mysql_use_result( MYSQL * ) */
|
||||
{
|
||||
HB_RETPTR( ( void * ) mysql_use_result( ( MYSQL * ) HB_PARPTR( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLFREER ) /* void mysql_free_result(MYSQL_RES *) */
|
||||
HB_FUNC( MYSQL_FREE_RESULT ) /* void mysql_free_result( MYSQL_RES * ) */
|
||||
{
|
||||
mysql_free_result( ( MYSQL_RES * ) HB_PARPTR( 1 ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLFETCHR ) /* MYSQL_ROW *mysql_fetch_row(MYSQL_RES *) */
|
||||
HB_FUNC( MYSQL_FETCH_ROW ) /* MYSQL_ROW * mysql_fetch_row( MYSQL_RES * ) */
|
||||
{
|
||||
MYSQL_RES * mresult = ( MYSQL_RES * ) HB_PARPTR( 1 );
|
||||
int num_fields = mysql_num_fields( mresult );
|
||||
@@ -192,17 +192,17 @@ HB_FUNC( SQLFETCHR ) /* MYSQL_ROW *mysql_fetch_row(MYSQL_RES *) */
|
||||
hb_itemReturnRelease( aRow );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLDATAS ) /* void mysql_data_seek(MYSQL_RES *, unsigned int) */
|
||||
HB_FUNC( MYSQL_DATA_SEEK ) /* void mysql_data_seek( MYSQL_RES *, unsigned int ) */
|
||||
{
|
||||
mysql_data_seek( ( MYSQL_RES * ) HB_PARPTR( 1 ), ( unsigned int ) hb_parni( 2 ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLNROWS ) /* my_ulongulong mysql_num_rows(MYSQL_RES *) */
|
||||
HB_FUNC( MYSQL_NUM_ROWS ) /* my_ulongulong mysql_num_rows( MYSQL_RES * ) */
|
||||
{
|
||||
hb_retnint( mysql_num_rows( ( ( MYSQL_RES * ) HB_PARPTR( 1 ) ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLFETCHF ) /* MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *) */
|
||||
HB_FUNC( MYSQL_FETCH_FIELD ) /* MYSQL_FIELD * mysql_fetch_field( MYSQL_RES * ) */
|
||||
{
|
||||
/* NOTE: field structure of MySQL has 8 members as of MySQL 3.22.x */
|
||||
PHB_ITEM aField = hb_itemArrayNew( 8 );
|
||||
@@ -223,36 +223,36 @@ HB_FUNC( SQLFETCHF ) /* MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *) */
|
||||
hb_itemReturnRelease( aField );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLFSEEK ) /* MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *, MYSQL_FIELD_OFFSET) */
|
||||
HB_FUNC( MYSQL_FIELD_SEEK ) /* MYSQL_FIELD_OFFSET mysql_field_seek( MYSQL_RES *, MYSQL_FIELD_OFFSET ) */
|
||||
{
|
||||
mysql_field_seek( ( MYSQL_RES * ) HB_PARPTR( 1 ), ( MYSQL_FIELD_OFFSET ) hb_parni( 2 ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLNUMFI ) /* unsigned int mysql_num_fields(MYSQL_RES *) */
|
||||
HB_FUNC( MYSQL_NUM_FIELDS ) /* unsigned int mysql_num_fields( MYSQL_RES * ) */
|
||||
{
|
||||
hb_retnl( mysql_num_fields( ( ( MYSQL_RES * ) HB_PARPTR( 1 ) ) ) );
|
||||
}
|
||||
|
||||
#if MYSQL_VERSION_ID > 32200
|
||||
|
||||
HB_FUNC( SQLFICOU ) /* unsigned int mysql_field_count( MYSQL * ) */
|
||||
HB_FUNC( MYSQL_FIELD_COUNT ) /* unsigned int mysql_field_count( MYSQL * ) */
|
||||
{
|
||||
hb_retnl( mysql_field_count( ( ( MYSQL * ) HB_PARPTR( 1 ) ) ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HB_FUNC( SQLLISTF ) /* MYSQL_RES *mysql_list_fields(MYSQL *, char *); */
|
||||
HB_FUNC( MYSQL_LIST_FIELDS ) /* MYSQL_RES * mysql_list_fields( MYSQL *, char * ); */
|
||||
{
|
||||
hb_retptr( mysql_list_fields( ( MYSQL * ) HB_PARPTR( 1 ), hb_parc( 2 ), NULL ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLGETERR ) /* char *mysql_error( MYSQL * ); */
|
||||
HB_FUNC( MYSQL_ERROR ) /* char * mysql_error( MYSQL * ); */
|
||||
{
|
||||
hb_retc( mysql_error( ( MYSQL * ) HB_PARPTR( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLLISTDB ) /* MYSQL_RES * mysql_list_dbs(MYSQL *, char * wild); */
|
||||
HB_FUNC( MYSQL_LIST_DBS ) /* MYSQL_RES * mysql_list_dbs( MYSQL *, char * wild ); */
|
||||
{
|
||||
MYSQL * mysql = ( MYSQL * ) HB_PARPTR( 1 );
|
||||
MYSQL_RES * mresult = mysql_list_dbs( mysql, NULL );
|
||||
@@ -271,7 +271,7 @@ HB_FUNC( SQLLISTDB ) /* MYSQL_RES * mysql_list_dbs(MYSQL *, char * wild); */
|
||||
hb_itemReturnRelease( aDBs );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLLISTTBL ) /* MYSQL_RES * mysql_list_tables(MYSQL *, char * wild); */
|
||||
HB_FUNC( MYSQL_LIST_TABLES ) /* MYSQL_RES * mysql_list_tables( MYSQL *, char * wild ); */
|
||||
{
|
||||
MYSQL * mysql = ( MYSQL * ) HB_PARPTR( 1 );
|
||||
char * cWild = hb_parc( 2 );
|
||||
@@ -290,30 +290,24 @@ HB_FUNC( SQLLISTTBL ) /* MYSQL_RES * mysql_list_tables(MYSQL *, char * wild); */
|
||||
hb_itemReturnRelease( aTables );
|
||||
}
|
||||
|
||||
/* returns bitwise and of first parameter with second */
|
||||
HB_FUNC( SQLAND )
|
||||
{
|
||||
hb_retnl( hb_parnl( 1 ) & hb_parnl( 2 ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLAFFROWS )
|
||||
HB_FUNC( MYSQL_AFFECTED_ROWS )
|
||||
{
|
||||
hb_retnl( ( long ) mysql_affected_rows( ( MYSQL * ) HB_PARPTR( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLHOSTINFO )
|
||||
HB_FUNC( MYSQL_GET_HOST_INFO )
|
||||
{
|
||||
hb_retc( mysql_get_host_info( ( MYSQL * ) HB_PARPTR( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SQLSRVINFO )
|
||||
HB_FUNC( MYSQL_GET_SERVER_INFO )
|
||||
{
|
||||
hb_retc( mysql_get_server_info( ( MYSQL * ) HB_PARPTR( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( DATATOSQL )
|
||||
HB_FUNC( MYSQL_ESCAPE_STRING )
|
||||
{
|
||||
const char * from = hb_parc( 1 );
|
||||
const char * from = hb_parcx( 1 );
|
||||
int iSize = hb_parclen( 1 );
|
||||
char * buffer = ( char * ) hb_xgrab( iSize * 2 + 1 );
|
||||
iSize = mysql_escape_string( buffer, from, iSize );
|
||||
@@ -328,8 +322,8 @@ static char * filetoBuff( char * fname, int * size )
|
||||
if( handle != FS_ERROR )
|
||||
{
|
||||
*size = ( int ) hb_fsSeek( handle, 0, FS_END );
|
||||
*size -= ( int ) hb_fsSeek( handle, 0, FS_SET );
|
||||
buffer = ( char * ) hb_xgrab( * size + 1 );
|
||||
hb_fsSeek( handle, 0, FS_SET );
|
||||
buffer = ( char * ) hb_xgrab( *size + 1 );
|
||||
*size = hb_fsReadLarge( handle, ( BYTE * ) buffer, *size );
|
||||
buffer[ *size ] = '\0';
|
||||
hb_fsClose( handle );
|
||||
@@ -340,7 +334,7 @@ static char * filetoBuff( char * fname, int * size )
|
||||
return buffer;
|
||||
}
|
||||
|
||||
HB_FUNC( FILETOSQLBINARY )
|
||||
HB_FUNC( MYSQL_ESCAPE_STRING_FROM_FILE )
|
||||
{
|
||||
int iSize;
|
||||
char * from = filetoBuff( hb_parc( 1 ), &iSize );
|
||||
@@ -353,3 +347,40 @@ HB_FUNC( FILETOSQLBINARY )
|
||||
hb_xfree( from );
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(HB_MYSQL_LEGACY_LEVEL_OFF)
|
||||
|
||||
HB_FUNC_EXTERN( MYSQL_GET_SERVER_VERSION ); HB_FUNC( SQLVERSION ) { HB_FUNC_EXEC( MYSQL_GET_SERVER_VERSION ); }
|
||||
HB_FUNC_EXTERN( MYSQL_REAL_CONNECT ); HB_FUNC( SQLCONNECT ) { HB_FUNC_EXEC( MYSQL_REAL_CONNECT ); }
|
||||
HB_FUNC_EXTERN( MYSQL_CLOSE ); HB_FUNC( SQLCLOSE ) { HB_FUNC_EXEC( MYSQL_CLOSE ); }
|
||||
HB_FUNC_EXTERN( MYSQL_COMMIT ); HB_FUNC( SQLCOMMIT ) { HB_FUNC_EXEC( MYSQL_COMMIT ); }
|
||||
HB_FUNC_EXTERN( MYSQL_ROLLBACK ); HB_FUNC( SQLROLLBACK ) { HB_FUNC_EXEC( MYSQL_ROLLBACK ); }
|
||||
HB_FUNC_EXTERN( MYSQL_SELECT_DB ); HB_FUNC( SQLSELECTD ) { HB_FUNC_EXEC( MYSQL_SELECT_DB ); }
|
||||
HB_FUNC_EXTERN( MYSQL_QUERY ); HB_FUNC( SQLQUERY ) { HB_FUNC_EXEC( MYSQL_QUERY ); }
|
||||
HB_FUNC_EXTERN( MYSQL_STORE_RESULT ); HB_FUNC( SQLSTORER ) { HB_FUNC_EXEC( MYSQL_STORE_RESULT ); }
|
||||
HB_FUNC_EXTERN( MYSQL_USE_RESULT ); HB_FUNC( SQLUSERES ) { HB_FUNC_EXEC( MYSQL_USE_RESULT ); }
|
||||
HB_FUNC_EXTERN( MYSQL_FREE_RESULT ); HB_FUNC( SQLFREER ) { HB_FUNC_EXEC( MYSQL_FREE_RESULT ); }
|
||||
HB_FUNC_EXTERN( MYSQL_FETCH_ROW ); HB_FUNC( SQLFETCHR ) { HB_FUNC_EXEC( MYSQL_FETCH_ROW ); }
|
||||
HB_FUNC_EXTERN( MYSQL_DATA_SEEK ); HB_FUNC( SQLDATAS ) { HB_FUNC_EXEC( MYSQL_DATA_SEEK ); }
|
||||
HB_FUNC_EXTERN( MYSQL_NUM_ROWS ); HB_FUNC( SQLNROWS ) { HB_FUNC_EXEC( MYSQL_NUM_ROWS ); }
|
||||
HB_FUNC_EXTERN( MYSQL_FETCH_FIELD ); HB_FUNC( SQLFETCHF ) { HB_FUNC_EXEC( MYSQL_FETCH_FIELD ); }
|
||||
HB_FUNC_EXTERN( MYSQL_FIELD_SEEK ); HB_FUNC( SQLFSEEK ) { HB_FUNC_EXEC( MYSQL_FIELD_SEEK ); }
|
||||
HB_FUNC_EXTERN( MYSQL_NUM_FIELDS ); HB_FUNC( SQLNUMFI ) { HB_FUNC_EXEC( MYSQL_NUM_FIELDS ); }
|
||||
HB_FUNC_EXTERN( MYSQL_FIELD_COUNT ); HB_FUNC( SQLFICOU ) { HB_FUNC_EXEC( MYSQL_FIELD_COUNT ); }
|
||||
HB_FUNC_EXTERN( MYSQL_LIST_FIELDS ); HB_FUNC( SQLLISTF ) { HB_FUNC_EXEC( MYSQL_LIST_FIELDS ); }
|
||||
HB_FUNC_EXTERN( MYSQL_ERROR ); HB_FUNC( SQLGETERR ) { HB_FUNC_EXEC( MYSQL_ERROR ); }
|
||||
HB_FUNC_EXTERN( MYSQL_LIST_DBS ); HB_FUNC( SQLLISTDB ) { HB_FUNC_EXEC( MYSQL_LIST_DBS ); }
|
||||
HB_FUNC_EXTERN( MYSQL_LIST_TABLES ); HB_FUNC( SQLLISTTBL ) { HB_FUNC_EXEC( MYSQL_LIST_TABLES ); }
|
||||
HB_FUNC_EXTERN( MYSQL_AFFECTED_ROWS ); HB_FUNC( SQLAFFROWS ) { HB_FUNC_EXEC( MYSQL_AFFECTED_ROWS ); }
|
||||
HB_FUNC_EXTERN( MYSQL_GET_HOST_INFO ); HB_FUNC( SQLHOSTINFO ) { HB_FUNC_EXEC( MYSQL_GET_HOST_INFO ); }
|
||||
HB_FUNC_EXTERN( MYSQL_GET_SERVER_INFO ); HB_FUNC( SQLSRVINFO ) { HB_FUNC_EXEC( MYSQL_GET_SERVER_INFO ); }
|
||||
HB_FUNC_EXTERN( MYSQL_ESCAPE_STRING ); HB_FUNC( DATATOSQL ) { HB_FUNC_EXEC( MYSQL_ESCAPE_STRING ); }
|
||||
HB_FUNC_EXTERN( MYSQL_ESCAPE_STRING_FROM_FILE ); HB_FUNC( FILETOSQLBINARY ) { HB_FUNC_EXEC( MYSQL_ESCAPE_STRING_FROM_FILE ); }
|
||||
|
||||
/* NOTE: Use hb_bitAnd() instead. Notice that latter will RTE on wrong arguments. */
|
||||
HB_FUNC( SQLAND )
|
||||
{
|
||||
hb_retnl( hb_parnl( 1 ) & hb_parnl( 2 ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -244,8 +244,8 @@ METHOD MakePrimaryKeyWhere() CLASS TMySQLRow
|
||||
for nI := 1 to Len(::aFieldStruct)
|
||||
|
||||
// search for fields part of a primary key
|
||||
if (sqlAND(::aFieldStruct[nI][MYSQL_FS_FLAGS], PRI_KEY_FLAG) == PRI_KEY_FLAG) .OR.;
|
||||
(sqlAND(::aFieldStruct[nI][MYSQL_FS_FLAGS], MULTIPLE_KEY_FLAG) == MULTIPLE_KEY_FLAG)
|
||||
if (hb_bitAnd(::aFieldStruct[nI][MYSQL_FS_FLAGS], PRI_KEY_FLAG) == PRI_KEY_FLAG) .OR.;
|
||||
(hb_bitAnd(::aFieldStruct[nI][MYSQL_FS_FLAGS], MULTIPLE_KEY_FLAG) == MULTIPLE_KEY_FLAG)
|
||||
|
||||
cWhere += ::aFieldStruct[nI][MYSQL_FS_NAME] + "="
|
||||
|
||||
@@ -347,19 +347,19 @@ METHOD New(nSocket, cQuery) CLASS TMySQLQuery
|
||||
::lFieldAsData := .T. //Use fields as object DATA. For compatibility
|
||||
::aRow := {} //Values of fields of current row
|
||||
|
||||
if sqlQuery(nSocket, cQuery) == 0
|
||||
if mysql_query(nSocket, cQuery) == 0
|
||||
|
||||
// save result set
|
||||
if !Empty(::nResultHandle := sqlStoreR(nSocket))
|
||||
if !Empty(::nResultHandle := mysql_store_result(nSocket))
|
||||
|
||||
::nNumRows := sqlNRows(::nResultHandle)
|
||||
::nNumFields := sqlNumFi(::nResultHandle)
|
||||
::nNumRows := mysql_num_rows(::nResultHandle)
|
||||
::nNumFields := mysql_num_fields(::nResultHandle)
|
||||
//DAVID:
|
||||
::aRow := Array( ::nNumFields )
|
||||
|
||||
for nI := 1 to ::nNumFields
|
||||
|
||||
aField := sqlFetchF(::nResultHandle)
|
||||
aField := mysql_fetch_field(::nResultHandle)
|
||||
AAdd(::aFieldStruct, aField)
|
||||
//DAVID:
|
||||
if ::lFieldAsData
|
||||
@@ -373,9 +373,9 @@ METHOD New(nSocket, cQuery) CLASS TMySQLQuery
|
||||
else
|
||||
// Should query have returned rows? (Was it a SELECT like query?)
|
||||
|
||||
if (::nNumFields := sqlNumFi(nSocket)) == 0
|
||||
if (::nNumFields := mysql_num_fields(nSocket)) == 0
|
||||
|
||||
// Was not a SELECT so reset ResultHandle changed by previous sqlStoreR()
|
||||
// Was not a SELECT so reset ResultHandle changed by previous mysql_store_result()
|
||||
::nResultHandle := nil
|
||||
|
||||
else
|
||||
@@ -394,15 +394,15 @@ return Self
|
||||
METHOD Refresh() CLASS TMySQLQuery
|
||||
|
||||
// free present result handle
|
||||
sqlFreeR(::nResultHandle)
|
||||
mysql_free_result(::nResultHandle)
|
||||
|
||||
::lError := .F.
|
||||
|
||||
if sqlQuery(::nSocket, ::cQuery) == 0
|
||||
if mysql_query(::nSocket, ::cQuery) == 0
|
||||
|
||||
// save result set
|
||||
::nResultHandle := sqlStoreR(::nSocket)
|
||||
::nNumRows := sqlNRows(::nResultHandle)
|
||||
::nResultHandle := mysql_store_result(::nSocket)
|
||||
::nNumRows := mysql_num_rows(::nResultHandle)
|
||||
|
||||
// NOTE: I presume that number of fields doesn't change (that is nobody alters this table) between
|
||||
// successive refreshes of the same
|
||||
@@ -465,7 +465,7 @@ METHOD Skip(nRows) CLASS TMySQLQuery
|
||||
//Clipper: only SKIP movement can set BOF() to .T.
|
||||
lbof := ::bof()
|
||||
|
||||
// sqlDataS(::nResultHandle, ::nCurRow - 1)
|
||||
// mysql_data_seek(::nResultHandle, ::nCurRow - 1)
|
||||
::getRow(::nCurrow)
|
||||
|
||||
if lbof
|
||||
@@ -512,7 +512,7 @@ METHOD GetRow(nRow) CLASS TMySQLQuery
|
||||
if nRow >= 1 .AND. nRow <= ::nNumRows
|
||||
|
||||
// NOTE: row count starts from 0
|
||||
sqlDataS(::nResultHandle, nRow - 1)
|
||||
mysql_data_seek(::nResultHandle, nRow - 1)
|
||||
::nCurRow := nRow
|
||||
//DAVID: else
|
||||
//DAVID: use current row ::nCurRow++
|
||||
@@ -528,7 +528,7 @@ METHOD GetRow(nRow) CLASS TMySQLQuery
|
||||
Afill( ::aRow, "" )
|
||||
|
||||
else
|
||||
::aRow := sqlFetchR(::nResultHandle)
|
||||
::aRow := mysql_fetch_row(::nResultHandle)
|
||||
endif
|
||||
|
||||
if ::aRow != NIL
|
||||
@@ -607,7 +607,7 @@ return iif(::aRow == NIL, NIL, oRow)
|
||||
// Free result handle and associated resources
|
||||
METHOD Destroy() CLASS TMySQLQuery
|
||||
|
||||
sqlFreeR(::nResultHandle)
|
||||
mysql_free_result(::nResultHandle)
|
||||
|
||||
return Self
|
||||
|
||||
@@ -621,7 +621,7 @@ METHOD Error() CLASS TMySQLQuery
|
||||
|
||||
::lError := .F.
|
||||
|
||||
return sqlGetErr(::nSocket)
|
||||
return mysql_error(::nSocket)
|
||||
|
||||
// Given a field name returns it's position
|
||||
METHOD FieldPos(cFieldName) CLASS TMySQLQuery
|
||||
@@ -889,7 +889,7 @@ METHOD Update(oRow, lOldRecord, lRefresh ) CLASS TMySQLTable
|
||||
cUpdateQuery += ::MakePrimaryKeyWhere()
|
||||
endif
|
||||
|
||||
if sqlQuery(::nSocket, cUpdateQuery) == 0
|
||||
if mysql_query(::nSocket, cUpdateQuery) == 0
|
||||
//DAVID: Clipper maintain same record pointer
|
||||
|
||||
//DAVID: after refresh(), position of current record is often unpredictable
|
||||
@@ -940,7 +940,7 @@ METHOD Update(oRow, lOldRecord, lRefresh ) CLASS TMySQLTable
|
||||
cUpdateQuery += oRow:MakePrimaryKeyWhere()
|
||||
endif
|
||||
|
||||
if sqlQuery(::nSocket, cUpdateQuery) == 0
|
||||
if mysql_query(::nSocket, cUpdateQuery) == 0
|
||||
|
||||
// All values are commited
|
||||
Afill(oRow:aDirty, .F.)
|
||||
@@ -1002,7 +1002,7 @@ METHOD Delete(oRow, lOldRecord, lRefresh) CLASS TMySQLTable
|
||||
cDeleteQuery += ::MakePrimaryKeyWhere()
|
||||
endif
|
||||
|
||||
if sqlQuery(::nSocket, cDeleteQuery) == 0
|
||||
if mysql_query(::nSocket, cDeleteQuery) == 0
|
||||
::lError := .F.
|
||||
//DAVID: Clipper maintain same record pointer
|
||||
//DAVID: ::nCurRow--
|
||||
@@ -1045,7 +1045,7 @@ METHOD Delete(oRow, lOldRecord, lRefresh) CLASS TMySQLTable
|
||||
cDeleteQuery += oRow:MakePrimaryKeyWhere()
|
||||
endif
|
||||
|
||||
if sqlQuery(::nSocket, cDeleteQuery) == 0
|
||||
if mysql_query(::nSocket, cDeleteQuery) == 0
|
||||
::lError := .F.
|
||||
|
||||
//DAVID: after refresh(), position of current record is often unpredictable
|
||||
@@ -1096,7 +1096,7 @@ METHOD Append(oRow, lRefresh) CLASS TMySQLTable
|
||||
// remove last comma from list of values and add closing parenthesis
|
||||
cInsertQuery := Left(cInsertQuery, Len(cInsertQuery) -1) + ")"
|
||||
|
||||
if sqlQuery(::nSocket, cInsertQuery) == 0
|
||||
if mysql_query(::nSocket, cInsertQuery) == 0
|
||||
::lError := .F.
|
||||
//DAVID: Clipper add record at end
|
||||
::nCurRow := ::lastrec() + 1
|
||||
@@ -1141,7 +1141,7 @@ METHOD Append(oRow, lRefresh) CLASS TMySQLTable
|
||||
// remove last comma from list of values and add closing parenthesis
|
||||
cInsertQuery := Left(cInsertQuery, Len(cInsertQuery) -1) + ")"
|
||||
|
||||
if sqlQuery(::nSocket, cInsertQuery) == 0
|
||||
if mysql_query(::nSocket, cInsertQuery) == 0
|
||||
//DAVID:
|
||||
::lError := .F.
|
||||
|
||||
@@ -1261,15 +1261,15 @@ return nil
|
||||
METHOD Refresh() CLASS TMySQLTABLE
|
||||
|
||||
// free present result handle
|
||||
sqlFreeR(::nResultHandle)
|
||||
mysql_free_result(::nResultHandle)
|
||||
|
||||
::lError := .F.
|
||||
|
||||
if sqlQuery(::nSocket, ::cQuery) == 0
|
||||
if mysql_query(::nSocket, ::cQuery) == 0
|
||||
|
||||
// save result set
|
||||
::nResultHandle := sqlStoreR(::nSocket)
|
||||
::nNumRows := sqlNRows(::nResultHandle)
|
||||
::nResultHandle := mysql_store_result(::nSocket)
|
||||
::nNumRows := mysql_num_rows(::nResultHandle)
|
||||
|
||||
// NOTE: I presume that number of fields doesn't change (that is nobody alters this table) between
|
||||
// successive refreshes of the same
|
||||
@@ -1303,8 +1303,8 @@ METHOD MakePrimaryKeyWhere() CLASS TMySQLTable
|
||||
for nI := 1 to Len(::aFieldStruct)
|
||||
|
||||
// search for fields part of a primary key
|
||||
if (sqlAND(::aFieldStruct[nI][MYSQL_FS_FLAGS], PRI_KEY_FLAG) == PRI_KEY_FLAG) .OR.;
|
||||
(sqlAND(::aFieldStruct[nI][MYSQL_FS_FLAGS], MULTIPLE_KEY_FLAG) == MULTIPLE_KEY_FLAG)
|
||||
if (hb_bitAnd(::aFieldStruct[nI][MYSQL_FS_FLAGS], PRI_KEY_FLAG) == PRI_KEY_FLAG) .OR.;
|
||||
(hb_bitAnd(::aFieldStruct[nI][MYSQL_FS_FLAGS], MULTIPLE_KEY_FLAG) == MULTIPLE_KEY_FLAG)
|
||||
|
||||
cWhere += ::aFieldStruct[nI][MYSQL_FS_NAME] + "="
|
||||
|
||||
@@ -1369,7 +1369,7 @@ METHOD New(cServer, cUser, cPassword) CLASS TMySQLServer
|
||||
::cServer := cServer
|
||||
::cUser := cUser
|
||||
::cPassword := cPassword
|
||||
::nSocket := sqlConnect(cServer, cUser, cPassword)
|
||||
::nSocket := mysql_real_connect(cServer, cUser, cPassword)
|
||||
::lError := .F.
|
||||
|
||||
if Empty( ::nSocket )
|
||||
@@ -1381,13 +1381,13 @@ return Self
|
||||
|
||||
|
||||
METHOD Destroy() CLASS TMySQLServer
|
||||
sqlClose(::nSocket)
|
||||
mysql_close(::nSocket)
|
||||
return Self
|
||||
|
||||
|
||||
|
||||
METHOD sql_commit() CLASS TMySQLServer
|
||||
if sqlCommit(::nSocket) == 0
|
||||
if mysql_commit(::nSocket) == 0
|
||||
Return .T.
|
||||
endif
|
||||
return .F.
|
||||
@@ -1395,7 +1395,7 @@ return .F.
|
||||
|
||||
|
||||
METHOD sql_rollback() CLASS TMySQLServer
|
||||
if sqlRollback(::nSocket) == 0
|
||||
if mysql_rollback(::nSocket) == 0
|
||||
Return .T.
|
||||
endif
|
||||
return .F.
|
||||
@@ -1403,14 +1403,14 @@ return .F.
|
||||
|
||||
METHOD sql_version() CLASS TMySQLServer
|
||||
local nVer
|
||||
nVer:=sqlversion(::nSocket)
|
||||
nVer:=mysql_get_server_version(::nSocket)
|
||||
return nVer
|
||||
|
||||
|
||||
|
||||
*METHOD SelectDB(cDBName) CLASS TMySQLServer
|
||||
*
|
||||
* if sqlSelectD(::nSocket, cDBName) == 0
|
||||
* if mysql_select_db(::nSocket, cDBName) == 0
|
||||
* ::cDBName := cDBName
|
||||
* return .T.
|
||||
* else
|
||||
@@ -1425,7 +1425,7 @@ METHOD SelectDB(cDBName) CLASS TMySQLServer
|
||||
|
||||
::lError := .F.
|
||||
|
||||
if sqlSelectD(::nSocket, cDBName) != 0 /* tabela nao existe */
|
||||
if mysql_select_db(::nSocket, cDBName) != 0 /* tabela nao existe */
|
||||
::cDBName :=""
|
||||
::lError := .T.
|
||||
else /* tabela existe */
|
||||
@@ -1440,7 +1440,7 @@ return .F.
|
||||
METHOD CreateDatabase ( cDataBase ) CLASS TMySQLServer
|
||||
local cCreateQuery := "CREATE DATABASE "+ lower(cDatabase)
|
||||
|
||||
if sqlQuery(::nSocket, cCreateQuery) == 0
|
||||
if mysql_query(::nSocket, cCreateQuery) == 0
|
||||
return .T.
|
||||
endif
|
||||
|
||||
@@ -1517,7 +1517,7 @@ METHOD CreateTable(cTable, aStruct,cPrimaryKey,cUniqueKey,cAuto) CLASS TMySQLSer
|
||||
|
||||
// remove last comma from list
|
||||
::cCreateQuery := Left(::cCreateQuery, Len(::cCreateQuery) -1) + ");"
|
||||
if sqlQuery(::nSocket, ::cCreateQuery) == 0
|
||||
if mysql_query(::nSocket, ::cCreateQuery) == 0
|
||||
return .T.
|
||||
else
|
||||
::lError := .T.
|
||||
@@ -1548,7 +1548,7 @@ METHOD CreateIndex(cName, cTable, aFNames, lUnique) CLASS TMySQLServer
|
||||
// remove last comma from list
|
||||
cCreateQuery := Left(cCreateQuery, Len(cCreateQuery) -1) + ")"
|
||||
|
||||
if sqlQuery(::nSocket, cCreateQuery) == 0
|
||||
if mysql_query(::nSocket, cCreateQuery) == 0
|
||||
return .T.
|
||||
|
||||
endif
|
||||
@@ -1560,7 +1560,7 @@ METHOD DeleteIndex(cName, cTable) CLASS TMySQLServer
|
||||
|
||||
local cDropQuery := "DROP INDEX " + cName + " FROM " + Lower(cTable)
|
||||
|
||||
if sqlQuery(::nSocket, cDropQuery) == 0
|
||||
if mysql_query(::nSocket, cDropQuery) == 0
|
||||
return .T.
|
||||
endif
|
||||
|
||||
@@ -1571,7 +1571,7 @@ METHOD DeleteTable(cTable) CLASS TMySQLServer
|
||||
|
||||
local cDropQuery := "DROP TABLE " + Lower(cTable)
|
||||
|
||||
if sqlQuery(::nSocket, cDropQuery) == 0
|
||||
if mysql_query(::nSocket, cDropQuery) == 0
|
||||
return .T.
|
||||
|
||||
endif
|
||||
@@ -1607,7 +1607,7 @@ METHOD Query(cQuery) CLASS TMySQLServer
|
||||
if nNumTables == 1
|
||||
oQuery := TMySQLTable():New(::nSocket, cQuery, cTableName)
|
||||
else
|
||||
oQuery := TMySQLQuery():New(::nSocket, cQuery)
|
||||
oQuery := TMymysql_query():New(::nSocket, cQuery)
|
||||
endif
|
||||
|
||||
if oQuery:NetErr()
|
||||
@@ -1621,14 +1621,14 @@ METHOD Error() CLASS TMySQLServer
|
||||
|
||||
::lError := .F.
|
||||
|
||||
return iif(Empty( ::nSocket ), "No connection to server", sqlGetErr(::nSocket))
|
||||
return iif(Empty( ::nSocket ), "No connection to server", mysql_error(::nSocket))
|
||||
|
||||
|
||||
METHOD ListDBs() CLASS TMySQLServer
|
||||
|
||||
local aList
|
||||
|
||||
aList := sqlListDB(::nSocket)
|
||||
aList := mysql_list_dbs(::nSocket)
|
||||
|
||||
return aList
|
||||
|
||||
@@ -1637,7 +1637,7 @@ METHOD ListTables() CLASS TMySQLServer
|
||||
|
||||
local aList
|
||||
|
||||
aList := sqlListTbl(::nSocket)
|
||||
aList := mysql_list_tables(::nSocket)
|
||||
|
||||
return aList
|
||||
|
||||
@@ -1653,12 +1653,12 @@ METHOD TableStruct(cTable) CLASS TMySQLServer
|
||||
local nRes, aField, aStruct, aSField, i
|
||||
|
||||
aStruct := {}
|
||||
nRes := sqlListF(::nSocket, cTable)
|
||||
nRes := mysql_list_fields(::nSocket, cTable)
|
||||
|
||||
if !Empty( nRes )
|
||||
for i := 1 to sqlNumFi(nRes)
|
||||
for i := 1 to mysql_num_fields(nRes)
|
||||
|
||||
aField := sqlFetchF(nRes)
|
||||
aField := mysql_fetch_field(nRes)
|
||||
aSField := Array(DBS_DEC)
|
||||
|
||||
// don't count indexes as real fields
|
||||
@@ -1705,7 +1705,7 @@ METHOD TableStruct(cTable) CLASS TMySQLServer
|
||||
endif
|
||||
next
|
||||
|
||||
sqlFreeR(nRes)
|
||||
mysql_free_result(nRes)
|
||||
|
||||
endif*/
|
||||
|
||||
@@ -1734,7 +1734,7 @@ static function ClipValue2SQL(Value)
|
||||
cValue="''"
|
||||
ELSE
|
||||
cValue := "'"
|
||||
Value:=DATATOSQL(value)
|
||||
Value:=mysql_escape_string(value)
|
||||
cValue+= value+ "'"
|
||||
ENDIF
|
||||
|
||||
|
||||
@@ -643,7 +643,7 @@ HB_FUNC( SQLSTOD )
|
||||
if( hb_parclen( 1 ) >= 10 )
|
||||
{
|
||||
char * szSqlDate = hb_parc( 1 ); /* YYYY-MM-DD */
|
||||
char szHrbDate[9]; /* YYYYMMDD */
|
||||
char szHrbDate[ 9 ]; /* YYYYMMDD */
|
||||
|
||||
szHrbDate[ 0 ] = szSqlDate[ 0 ];
|
||||
szHrbDate[ 1 ] = szSqlDate[ 1 ];
|
||||
|
||||
@@ -62,6 +62,8 @@
|
||||
|
||||
#if defined(HB_OS_WIN)
|
||||
|
||||
BOOL WINAPI HB_EXPORT DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved );
|
||||
|
||||
BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %p)", hInstance, fdwReason,
|
||||
@@ -74,12 +76,12 @@ BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserve
|
||||
switch( fdwReason )
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
hb_vmInit( FALSE ); /* Don't execute first linked symbol */
|
||||
break;
|
||||
hb_vmInit( FALSE ); /* Don't execute first linked symbol */
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
hb_vmQuit();
|
||||
break;
|
||||
hb_vmQuit();
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -74,10 +74,10 @@ BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserve
|
||||
switch( fdwReason )
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
break;
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -78,8 +78,6 @@
|
||||
#if defined(HB_OS_WIN)
|
||||
HB_EXTERN_BEGIN
|
||||
|
||||
BOOL WINAPI HB_EXPORT DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved );
|
||||
|
||||
static FARPROC hb_getProcAddress( LPCSTR szProcName )
|
||||
{
|
||||
static HMODULE s_hModule = NULL;
|
||||
@@ -111,6 +109,8 @@ static FARPROC hb_getProcAddress( LPCSTR szProcName )
|
||||
return pProcAddr;
|
||||
}
|
||||
|
||||
BOOL WINAPI HB_EXPORT DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved );
|
||||
|
||||
BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %d)", hInstance, fdwReason,
|
||||
|
||||
Reference in New Issue
Block a user