Page 1 of 1

DatabaseRows()

Posted: Fri Jan 13, 2006 9:30 pm
by Flype
About Database functions, in PHP language we can do :

Code: Select all

$nbresult = mysql_num_rows($result)
A native DatabaseRows() function could be useful for counting the number of rows after a DatabaseQuery(). DatabaseColumns() exists so why not for Rows.

Code: Select all

Procedure.l DatabaseRows()
  Protected i
  i=0
  While NextDatabaseRow()
    i+1
  Wend
  ProcedureReturn i
EndProcedure

If DatabaseQuery("select * from test;")
  Debug DatabaseRows()
Else
  Debug DatabaseError()
EndIf

Posted: Sat Jan 14, 2006 7:44 pm
by Manol

Code: Select all

#Database=0
Name$="You DataBase Name"
InitDatabase()
OpenDatabase(#Database, Name$, User$, Password$)
DatabaseQuery("select COUNT(*) from test;")
If DatabaseError()
Debug "Error"
Else
NextDatabaseRow() 
  Debug GetDatabaseLong(0)
EndIf 
  
:wink:

Posted: Sat Jan 14, 2006 9:14 pm
by Flype
thank you man.
but i need to count lines by myself on some special sql request where COUNT(...) doesn't work as wanted.
:wink: