Page 2 of 2

Posted: Mon Nov 15, 2004 3:39 pm
by dige
mysql_num_rows always return #NULL!

I found the reason in the manual:
The use of mysql_num_rows() depends on whether you use mysql_store_result() or mysql_use_result() to return the result set. If you use mysql_store_result(), mysql_num_rows() may be called immediately. If you use mysql_use_result(), mysql_num_rows() will not return the correct value until all the rows in the result set have been retrieved.
You should change MySQL_Use_Result () to MySQL_Store_Result ()

cya dige

Posted: Mon Nov 15, 2004 7:02 pm
by Max.²
I used mysql_use_result and ...store_result some time ago to check which function is faster, but forgot to mention it here, but did in the german one. :roll:

*mysqlResult=MySQL_Use_Result (dbHnd)

;no result returned
If *mysqlResult=0
;no fields returned means error
If MySQL_Field_Count(dbHnd)
MySQL_GetError(dbHnd,1)
;fields are returned, so no error but query didn't return data
Else

EndIf
;results are returned
Else
;i am using MySQL_Use_Result here, so affRows and rowsNum cannot be retrieved.
;the function MySQL_Store_Result behaves a bit differently (only a bit)
;and you could use the functions I did comment.
;please consult the MySQL documentation for further infos.

;affRows = CallFunction(#libmysql,"mysql_affected_rows",dbHnd)
fieldNum = CallFunction(#libmysql,"mysql_num_fields",*mysqlResult)
;rowsNum = CallFunction(#libmysql,"mysql_num_rows",*mysqlResult)

Debug affRows
Debug fieldNum
Debug rowsNum