TMySQLServer

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 2161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 469 times
Been thanked: 108 times
Contact:

TMySQLServer

Post by serge_girard » Fri Dec 07, 2018 4:25 pm

Hello,

I need to know the number of rows that are inserted/updated/deleted. This function is called 'affected_rows' (in PHP- MySQL)
Apparantly it is missing in Harbour and now I managed to find out how, but still it doesn't work.

Code: Select all

cSQL := "DELETE FROM table WHERE something..."
cQuery	:= dbo:Query( cSQL )

nAFF     := dbo:affected_rows() 
? 'dbo:className', dbo:className()		-->TMYSQLSERVER INSTEAD OF TMy2SQLServer


CREATE CLASS TMy2SQLServer INHERIT TMySQLServer   
METHOD affected_rows()                       
ENDCLASS

METHOD affected_rows() CLASS TMy2SQLServer        
RETURN mysql_affected_rows( ::nSocket )
The 'new' function however always refers to TMYSQLSERVER instead of TMy2SQLServer.
My knowledge of Classes/Methods is poor. Someone knows whar or how to make it work?

Thx, Serge

User avatar
susviela
Posts: 9
Joined: Wed Oct 17, 2018 4:44 am
DBs Used: DBF, PostgreSql, SQLite
Has thanked: 4 times
Contact:

Post by susviela » Fri Dec 07, 2018 4:33 pm

Test:

SELECT ROW_COUNT();

https://stackoverflow.com/questions/430 ... -statement

-----------
OR

one way, not very optimal is to simply do a select before you do the update.

select count(*) from table1 where country = 'country1'

User avatar
serge_girard
Posts: 2161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 469 times
Been thanked: 108 times
Contact:

Post by serge_girard » Fri Dec 07, 2018 9:44 pm

Thanks Susviela, that is exactly what I am doing now: count before, ask for confirmation, then execute or not.
After execution I do a select row_count to see if first count and row_count matches, if not something has changed in between... This works fine but I was wondering why the affected_rows method isn't working as it should.
I was told to change contrib\hbmysql\tmysql.prg but I cannot find this file in my hmg folders.

Serge

User avatar
vagblad
Posts: 110
Joined: Tue Jun 18, 2013 12:18 pm
DBs Used: MySQL,DBF
Location: Thessaloniki, Greece
Has thanked: 12 times
Been thanked: 18 times

Post by vagblad » Mon Dec 10, 2018 9:44 am

Serge,

Maybe it is silly to ask this but did you instantiate the dbo object like this?
dbo := TMy2SQLServer():New(cServer,cUsername,cPassword,nPort)
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad

User avatar
serge_girard
Posts: 2161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 469 times
Been thanked: 108 times
Contact:

Post by serge_girard » Mon Dec 10, 2018 1:26 pm

Hello Vagelis,

No, I did not!

I now tried and it works..!
Brilliant thinking Vagelis !

Thank you so much,

Serge

Post Reply