TMySQLServer

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 3162
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

TMySQLServer

Post by serge_girard »

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
There's nothing you can do that can't be done...
User avatar
susviela
Posts: 24
Joined: Wed Oct 17, 2018 4:44 am
DBs Used: DBF, PostgreSql, SQLite
Contact:

Re: TMySQLServer

Post by susviela »

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: 3162
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: TMySQLServer

Post by serge_girard »

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
There's nothing you can do that can't be done...
User avatar
vagblad
Posts: 160
Joined: Tue Jun 18, 2013 12:18 pm
DBs Used: MySQL,DBF
Location: Thessaloniki, Greece

Re: TMySQLServer

Post by vagblad »

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: 3162
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: TMySQLServer

Post by serge_girard »

Hello Vagelis,

No, I did not!

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

Thank you so much,

Serge
There's nothing you can do that can't be done...
Post Reply