Better database-support

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Better database-support

Post by Kukulkan »

Hi,

I currently work on a mid-size commercial application that needs a MySQL database. I connect using the PB-internal ODBC-methods.

Here are my wishes:

After a call to DatabaseQuery(), the row-cursor should be on the first returned row. I allways have to call NextDatabaseRow() to get the first results. That is unusually.

I need a command to get the number of results! Something like DatabaseRowCount().

There should be more commands to move the row-cursor: DatabaseMoveFirstRow() and DatabaseMoveLastRow() would be verry good.

Something like DatabaseEOF() and DatabaseBOF(). If I use NextDatabaseRow() to verify the end of the results, the cursor moves if I'm not. I want to check this, without moving the cursor (like in other languages like VB using ADO EOF() and BOF()).

A way to filter the results again! Something like the Filter-Flag of ADO: Filterstring.s = "Value > 500": DatabaseFilter(Filterstring.s)

I need a direct way to reach values in a row. Something like GetDatabaseString("ColumnName") instead of heaving to know the column-number. If I query with SELECT * FROM... I really not know the right column in many cases.

I miss the possibility of selecting, if the cursor is server-side or client-side. Maybe this is possible in ODBC or do I have to select this in the User-DSN on windows?

Ok, this have been my wishes for using databases.

Kukulkan
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

I need a direct way to reach values in a row. Something like GetDatabaseString("ColumnName") instead of heaving to know the column-number. If I query with SELECT * FROM... I really not know the right column in many cases.
I use this small procedure:

Code: Select all

Procedure GetDatabaseColumn(name$)
  For N=0 To DatabaseColumns()
    If DatabaseColumnName(N)=name$
      ProcedureReturn N
    EndIf
  Next N
  ProcedureReturn -1
EndProcedure
Tranquil
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post by Kukulkan »

Hi tranquil,

Thank you, but I created a routine for myself that does nearly exactly the same than yours. But this needs time and slows down the program. A good programming-language should offer something like this.

Kukulkan
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

I agree!
Tranquil
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Kukulkan,

PBs database is extremely lightweight for speed and efficiency.

For readable code create constants for the column names. All of the readability but with no runtime overhead.

VB doesn't have any database support at all. It uses Microsoft's ADODB components. Purebasic can use exactly the same library.

The comlib user library includes examples of how to use ADODB.
http://www.purearea.net/pb/download/use ... B_demo.zip
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post by Kukulkan »

Thank you GedB,

This are good hints, but this is not changing my wishes. If those wishes where realized, I really can forget ADO and the other bullshit of MS. This will result in small and fast PB-executables without the need of any additional MS-components. This is the vision...

Kukulkan
User avatar
the.weavster
Addict
Addict
Posts: 1576
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Post by the.weavster »

REALbasic Pro has a MySQL plugin that enables you to very easily create an app that works with MySQL and you end up with a cross-platform self contained *.exe which doesn't require any external resources.

You do have to set the server to use the old password algorithm as the plugin needs updating but it's easy to do.

Don't expect the *.exe to be of the tiny dimensions created by PureBasic though.
Post Reply