DBSqlite

BlitzMax Forums/Brucey's Modules/DBSqlite

Eternal Crisis(Posted 2010) [#1]
Sorry if this may have been answered somewhere, I had searched the forums for a while and didn't come up with anything.

Curious if there is a "results" method/function?

For example;

local q:tdatabasequery = db.executequery("SELECT * FROM blah")

' for example "q.results()"
  if q.results() > 0
  '..do whatever
  else
    print "No records found."
  endif


Thanks.


Kurator(Posted 2010) [#2]
look into the tests folder in the dbsqlite.mod directory, there are some examples for using it like:

	Local query:TDatabaseQuery = db.executeQuery("SELECT * from person")
	If db.hasError() Then
		errorAndClose(db)
	End If

	While query.nextRow()
		Local record:TQueryRecord = query.rowRecord()
		
		DebugLog("Name = " + TDBString(record.value(1)).value + " " + TDBString(record.value(2)).value)
	Wend



Eternal Crisis(Posted 2010) [#3]
Sorry, I should have been more clear. An example like "q.results()" to return how many results were retrieved from the database after a SELECT query.


Kurator(Posted 2010) [#4]
hm, as far as I know the rowcount is not set by sqllite, so you only now the number of rows returned only if you iterate over them and count them.

[edit] but you can do a sql query with an count() and determine this way the number of data ;)


Eternal Crisis(Posted 2010) [#5]
Bah, didn't think of that, thanks Kurator.